使用ant替换css的多个可变内容行

发布于 2024-12-08 09:59:04 字数 1268 浏览 0 评论 0原文

我有一个带有变量部分的 css 文件,当我运行构建脚本时,我想从文件中删除该变量部分(但我需要将该部分保留在源代码中)。我想我应该用某种标记将该部分包装在注释中(/*remove-front/&/remove-back*/),然后使用ant替换注释之间的所有内容什么也没有。

这是我的例子:

/* 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 */

提前感谢您的回复。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

鸩远一方 2024-12-15 09:59:04

我和@FailedDev有同样的想法,但是当尝试我的Eclipse时,它对“m”选项犹豫不决(并且我添加了使用 /*remove-front */ 的功能(空格)和 /*REMOVE-BACK*/ (不区分大小写):

<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 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"/>
抱猫软卧 2024-12-15 09:59:04

我将使用标准的replaceregexp任务:

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

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

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"
/>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文