javascript - generating templates with grunt - looking for a task -
i've got html file following content:
<html> <body> <span>{{ secret }}</span> </body> </html>
i'm looking grunt task take source file, take map of values:
grunt.initconfig({ mytask: { mytarget: { src: ... dest: ... values: { secret: 'abc' } } } })
and generate output file:
<html> <body> <span>abc</span> </body> </html>
is there task this? saw grunt-mustache-html forces lots of things exist don't need , don't want use it. want take single mustache (or hbs or whatever), fill data grunt-level object , dump result html file, that's all.
you try grunt-template processed lo-dash templates. here's basic setup solve problem:
//gruntfile.js config.template = { mytask: { options: { data: function () { return { secret: 'abc' }; } }, files: { 'output.html: ['template.html.tpl'] } } }; //template.html.tpl <html> <body> <span><%= secret %></span> </body> </html>
Comments
Post a Comment