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

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -