开发者

replace multiple variable content lines of css using ant

I have a css file with a variable section that I want to remove from the file when I run my build script (but I'll need to keep the section in the source). I'm thinking I'd wrap the section in comments (/* remove-front / & / remove-back */) with some sort of tokens and then use ant to replace everything between the comments with nothing.

Here's my example:

/* remove-front */
.footerGradients {
  /* gradient settings (used http://www.colorzilla.com/gradient-editor/ to generate following code) */

  background-color: 开发者_高级运维#606869;
  background: -webkit-gradient(linear, left bottom, left top, color-stop(0, #2f3838), color-stop(100%, #606869));
  background: -moz-linear-gradient(center bottom, #2f3838 0, #606869 100%);
  background: -ms-linear-gradient(center bottom, #2f3838 0, #606869 100%);
  background: -o-linear-gradient(center bottom, #2f3838 0, #606869 100%);
  background: linear-gradient(center bottom, #2f3838 0, #606869 100%);
  -pie-background: linear-gradient(#2f3838, #606869);
  filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=#2f3838,endColorstr=#606869);
  /* end gradient settings */

}
.footerShadows {
  /* box shadow settings (used http://css3generator.com/ to generate following code) */

  -webkit-box-shadow: 0 0 2px 0 #293535;
  -moz-box-shadow: 0 0 2px 0 #293535;
  box-shadow: 0 0 2px 0 #293535;
  /* end box shadow settings */

}
/* remove-back */

Thanks in advance for your response.


I had the same thought as @FailedDev, but when trying out my Eclipse, it was balking at the "m" option (and I've added a the ability to use /*remove-front */ (spaces) and /*REMOVE-BACK*/ (case-insensitivity):

<copy tofile="src/test2.css" file="src/test.css" overwrite="true"/>
<replaceregexp 
   file="src/test2.css" 
   match="/\*\s*remove-front\s*\*/.*?/\*\s*remove-back\s*\*/"
   replace=""
   flags="gsi" 
   byline="false"/>


I would use the standard replaceregexp task :

http://ant.apache.org/manual/Tasks/replaceregexp.html

 <replaceregexp file="${css.file}"
                match="/\* remove-front \*/.*?/\* remove-back \*/"
                replace=""
                byline="false"
                flags="gs"
/>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜