你可能永远不会使用这个方法,因为你所使用的 grunt.template.process
在内部使用的就是这个方法。
grunt.template.setDelimiters(name)
grunt.template.addDelimiters
为Lo-Dash模板添加一个命名分隔符。你或许不需要使用这个方法,因为内置的分割符应该足以满足需求了,但是你仍可以随时添加{% %}
或者[% %]
风格的分隔符。
name
参数应当是唯一的,因为这也是我们通过 grunt.template.setDelimiters
获取分隔符的方式,并且后续作为 grunt.template.process
的一个选项来使用。
grunt.template.addDelimiters(name, opener, closer)
在此实例中,如果我们希望使用 {% %}
形式的分隔符,我们需要如下这样设置:
grunt.template.addDelimiters('myDelimiters', '{%', '%}')
助手函数
grunt.template.date
使用dateformat library格式化一个日期。
grunt.template.date(date, format)
在这个案例中,指定的日期被格式化为 month/day/year。
grunt.template.date(847602000000, 'yyyy-mm-dd') // '1996-11-10'
grunt.template.today
使用 dateformat library格式化当前日期。
grunt.template.today(format)
在这个案例中,当前日期被格式化为4位数字表示的年份。
grunt.template.today('yyyy') // '2014'
标签:Grunt
相关阅读 >>
更多相关阅读请进入《Grunt》频道 >>

Vue.js 设计与实现 基于Vue.js 3 深入解析Vue.js 设计细节
本书对 Vue.js 3 技术细节的分析非常可靠,对于需要深入理解 Vue.js 3 的用户会有很大的帮助。——尤雨溪,Vue.js作者