grunt-underscore-jst
Precompile Underscore template to JST, a node module, also a grunt plugin, also a gulp plugin. The generated code is not dependent on underscore.
Grunt plugin
This plugin requires Grunt ~0.4.2
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-underscore-jst --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt;
The "underscore_jst" task
Overview
In your project's Gruntfile, add a section named underscore_jst
to the data object passed into grunt.initConfig()
.
grunt;
Options
options.templateSettings
Type: Object
Default value: {}
See: _.template() argument options
A string value that is used to do something with whatever.
options.outputSettings
Type: Object
Default value: {}
A string value that is used to do something else with whatever else.
options.outputSettings.style
Type: string
or Object
Default Value: 'kmd'
- when is
string
, it's enumerable, ie 'kmd' or 'amd' - when is
Object
,options.outputSettings.style.namespace
is the jst variable name
options.outputSettings.withModName
Type: boolean
Default Value: false
When options.outputSettings.style
is enuerable, it tells whether generate modName
options.outputSettings.processName(filepath)
Type: Function
Default Value: null
- argument
filepath
is the file path return
value ismodName
options.outputSettings.processContent(text)
Type: Function
Default Value: string
- argument
text
is the file content; return
value is the content to be compiled
options.outputSettings.beautify
Type: boolean
Default Value: true
Whether pretty the compiled js code
Node module
var compiler = ; var result = compiler; if !resulterror console;
generateModule(text, templateSettings, outputSettings)
- parameters document plz see lib/main.js