Page 461 - AngularJS权威教程
P. 461
34.4 grunt-angular-templates 441
2. concat 19
concat是concat定义内的目标名称,这是你要添加编译后的模板路径的地方。
3. htmlmin 20
正如可以压缩CSS和JavaScript文件一样,还可以使用一个叫做(意料之中)htmlmin的工具
来压缩HTML。grunt-angular-templates能够很好地和htmlmin一起工作,此外,它甚至还允 21
许压缩模板内的HTML。
你可以在配置内为htmlmin设置选项,就像这样: 22
ngtemplates: {
myApp: { 23
options: {
htmlmin: {
collapseBooleanAttributes: true,
collapseWhitespace: true, 24
removeAttibuteQuotes: true,
removeEmptyAttributes: true,
removeRedundantAttributes: true, 25
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true
}
} 26
}
}
4. module 27
angular.module的名称,模板缓存会将这个名称注册为模板要缓存的模块。
28
ngtemplate: {
myApp: {
options: { 29
module: 'myBestApp'
}
}
} 30
因此将会看到以下方式的模板设置:
31
angular.module('myBestApp')
.run(['$templateCache'],
function($templateCache) {
// ... 32
});
5. prefix 33
我们可以为所有的模板URL设置一个前缀。例如,如果想使用绝对URL来存取来自不同目录
中绝对位置的模板,要像这样设置前缀: 34
ngtemplate: {
app: {
options: { 35
prefix: '/public'
}
} 36
}