2014-09-05 60 views
1

我从步兵移动吞掉,和我以前用的模板在我Grunfile.js配置我的任务,如咕噜描述hereGulp中的Grunt风格模板?

模板看起来像这样的:

<%= blahblah.static %> 
<%= blahblah.build %> 

和我无法找到如何实现与咕嘟咕嘟同样的事情任何有用的文档...

+2

为什么不使用正常的js? 'var s ='something'+ variable +'here''。 Grunt使用模板,因为当你在'initConfig'中定义它时,你不能在配置中引用其他变量。 – parchment 2014-09-05 08:21:38

回答

0

如果你有一些复杂的字符串来构建,你可以随时使用下划线模板:

var _ = require('underscore'); 

var tmpl = _.template('var 1: <%= var1 %>, var 2: <%= var2 %>, etc...'); 

//... 

tmpl({var1: 'hello', var2: 'world'}); 

否则,只需使用普通的js字符串连接。