[Grunt] grunt.template

/**
 * Created by Answer1215 on 11/15/2014.
 */
module.exports = function(grunt){
    grunt.initConfig({
        files: ["'js'", "html"],
        compile: "<%- files %>" //encoding charater
    }); //compile: "<%= files %>" //no encoding

    grunt.registerTask("default", function(){
        grunt.log.writeln(grunt.config.get("compile")); //js, html
        grunt.log.writeln(grunt.template.process("<%= files %>")); //js.html
        grunt.log.writeln(grunt.template.today('yyyy-mm-dd')); //2014-11-15
    });
}

Template strings can be processed manually using the provided template functions. In addition, the config.get method (used by many tasks) automatically expands <% %> style template strings specified as config data inside the Gruntfile.

Read More:  http://gruntjs.com/api/grunt.template

posted @ 2014-11-15 23:02  Zhentiw  阅读(233)  评论(0)    收藏  举报