【发布时间】:2015-04-14 21:47:44
【问题描述】:
我有大约 10 个文件,例如:file1.html、file2.html、fil31.html、file4.html
每个文件都包含一个带有空白 id='' 字段的开始和结束脚本标记
我想为每个文件中的所有脚本标签添加 id。
id 是文件名。
before running grunt
eg: file1.html
<script type='text/ng-template' id=''>
<div>Couple of other dive tags</div>
</script>
after running grunt the id filed should have an if which is the file name
eg: file1.html
<script type='text/ng-template' id='file1.html'>
<div>Couple of other dive tags</div>
</script>
我已经尝试过使用几个 grunt 包,但不知道如何让它们选择文件名并将它们添加为 id。
grunt file_append
grunt-script-link-tags
有没有人遇到过同样的问题或知道如何解决这个问题?
【问题讨论】:
-
你在做一个纯 HTML 项目吗?你看过像 nunjucks github.com/vitkarpov/grunt-nunjucks-2-html 这样的 JS/HTML 模板吗?
标签: gruntjs grunt-contrib-concat grunt-plugins gruntfile grunt-html-build