precompile jqoteplus templates
前端模板可以让我们很简单的组建一系列复杂的html结构。在项目的累积中,所用的模板越来越多,使用模板的第一步是将模板解析成function再执行,为了节省浏览器的解析编译花费的时间,所以我们可以将这一步提前完成。所以有了jqoteplus-build的诞生。
模板需要定义在<script type="text/x-jqote-template" id="key"></script>
标签中,type
为标示符,id
为key,在jqoteplus调用$.jqote('key', data)
This plugin requires Grunt ~0.4.4
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install jqoteplus-build --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('jqoteplus-build');
In your project's Gruntfile, add a section named jqoteplus_build
to the data object passed into grunt.initConfig()
.
grunt.initConfig({
jqoteplus_build: {
build: {
src: [],
options: {
exclude: [],
deployPath: '',
deployName: ''
}
}
},
});
Type: Array
Default value: ``
定义需要预编译的文件数组
Type: Array
Default value: none
用于定义不需要预编译的文件名/路径数组。
Type: String
Default value: none
编译后的文件路径
Type: String
Default value: templatefunc.js
编译后的文件名字
定义test/jqote
下面的所有ftl后缀文件都需要编译。exclude说明包含test/jqote/read
的文件路径或者文件名字不需要编译,deployPath
和deployName
组合起来就是最后编译结果路径。
grunt.initConfig({
jqoteplus_build: {
build: {
src: ['test/jqote/**/*.ftl'],
options: {
exclude: ['test/jqote/read'],
deployPath: 'test/build/',
deployName: 'template.js'
}
}
},
});
###0.1.2 release