underscore-tpl
_.template
for objects
Installation
Bower
bower install underscore-tpl
Npm
npm install underscore-tpl
Usage
API
_tpl( subject, values, [settings])
Example
var _tpl = ;var values = foo : "foo" badass : "Jules Winfield" qux : mofo : "mofo" ; var config = baz : "<%= qux.mofo %>" major : badass : "<%= badass %>" "<%= foo %>" : "bar"; console;
# output
Settings
_tpl
accepts all _.template
settings and adds a few more:
ignoreKeys
[Boolean]: whentrue
object keys will not be interpolated. (Default:false
)mustache|handlebars
[Boolean]: whentrue
you can use mustache style tags{{ }}
instead of ERB.
These can be set either in the settings
parameter of _tpl, e.g.:
var results = ;
or globally:
_tpltemplateSettingsignoreKeys = true;
License
Released under MIT license