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

Gruntjs 使用grunt在脚本标记中添加变量id,gruntjs,grunt-contrib-concat,grunt-plugins,gruntfile,grunt-html-build,Gruntjs,Grunt Contrib Concat,Grunt Plugins,Gruntfile,Grunt Html Build,我有大约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> &

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


你在做一个pur HTML项目吗?你看过像nunjucks这样的JS/HTML模板吗?
grunt file_append
grunt-script-link-tags