【问题标题】:Insert id's into script tags using grunt使用 grunt 将 id 插入到脚本标签中
【发布时间】:2015-04-15 21:59:11
【问题描述】:

我想在脚本标签中插入id

gruntfile.js

var obj = ['id1', 'id2', 'id3'];
var i = 0;

grunt.initConfig({
    concat:{
                    basic:{
                        options:{                               
                            banner:'<script type="text/ng-template" id=' +obj[i] + ' >',
                            separator:'</script><script type="text/ng-template" id=' + obj[i++] + ' >',
                            footer:'</script>'
                        },
                        files:[{
                            src:['./src/folder/*.html'],
                            dest:'./src/foler/index.ftl'
                        }]
                    }
        }
})

但在文件连接到 index.ftl 时的输出中,所有 id 都具有相同的 id='id3'

如何获得具有所有唯一 ID 的最终连接文件。

【问题讨论】:

    标签: gruntjs grunt-contrib-watch grunt-contrib-concat


    【解决方案1】:

    以下链接解决了这个问题中添加ID的部分, 我创建了自己的 wrap 插件并在代码中使用它来动态添加 id,

    Replace all the text with specified replacement using grunt replace

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-12-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多