【发布时间】:2016-08-25 10:17:10
【问题描述】:
以下是来自http://gruntjs.com/getting-started 的示例 gruntjs
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
uglify: {
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
},
build: {
src: 'src/<%= pkg.name %>.js',
dest: 'build/<%= pkg.name %>.min.js'
}
}
});
// Load the plugin that provides the "uglify" task.
grunt.loadNpmTasks('grunt-contrib-uglify');
// Default task(s).
grunt.registerTask('default', ['uglify']);
};
然后提到:
由于 模板字符串可以引用任何配置属性,因此可以通过这种方式指定文件路径和文件列表等配置数据以减少重复。
我的问题:
<%= %>是什么意思?它是 gruntjs 语法还是在其他地方普遍使用?我在哪里可以找到它的定义?您搜索神秘符号解释的一般方法是什么?如果我在 google/stackoverflow 中搜索这些字符串(“
<%=”、“<%”,包括引号与否),基本上不会出现合理的结果。
【问题讨论】:
-
同意上面的#2。我不得不谷歌“percent equals grunt”才能找到这个帖子。
<%=没有产生任何结果,因为它们是如何被搜索引擎使用的。
标签: javascript gruntjs javascript-objects