grunt-browserify-jst
v1.0.1
Published
JST templates compiler to use with grunt-browserify
Downloads
1
Readme
grunt-browserify-jst
Grunt plugin for JST templates compillation. Precompiles Underscore templates to JST file to use with grunt-browserify.
Getting Started
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 grunt-browserify-jst --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-browserify-jst');
browserify-jst task
Run this task with the grunt browserify-jst
command.
Task targets, files and options may be specified according to the grunt Configuring tasks guide.
_This plugin uses the Underscore library to generate JavaScript template functions. Some developers generate template functions dynamically during development. If you are doing so, please be aware that the functions generated by this plugin may differ from those created at run-time.
Options
processName
Type: function
Default: null
This option accepts a function which takes one argument (the template filepath) and returns a string which will be used as the key for the precompiled template object. The example below stores all templates on the default namespace in capital letters.
options: {
processName: function(filepath) {
return filepath.toUpperCase();
}
}
Sample configuration
'browserify-jst': {
compile: {
options: {
processName: function(filepath) {
return filepath.toUpperCase();
}
},
src : 'path/**/*.html',
dest : 'jst.js'
}
}
Usage in the code
var jst = require('./jst');
template = jst['MY-TEMPLATE'];
var markup = template({/* template parameters */});