使用 grunt 在脚本标记中添加变量 ID



>我有大约 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>

我已经通过使用几个咕噜咕噜的软件包进行了尝试,但无法弄清楚如何让它们选择文件名并将它们添加为 id。

grunt file_append
grunt-script-link-tags

有没有人遇到过同样的问题或知道如何解决这个问题?

使用以下代码在脚本标记中动态添加 id。

使用咕噜声替换用指定的替换替换所有文本

最新更新