[Grunt] grunt.template

本文详细介绍了如何利用Grunt配置文件中的模板字符串功能来处理JS和HTML文件,包括手动处理模板字符串和自动展开特性。
/**
 * 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

转载于:https://www.cnblogs.com/Answer1215/p/4100784.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值