browserify transform for dust template files
npm install browserify-dustjs --save-dev
var template = require("../views/template.dust");
template({title:"Browserify is Awesome!", mood:"happy"}, function(err, html) {
// Deal with html
});
template(function(err, html) {
// Also works without context
});
To use it from the command line:
browserify -t browserify-dustjs file.js
To use it from node:
var browserify = require('browserify');
var dustify = require('browserify-dustjs');
var b = browserify();
b.add('view.js');
b.transform(dustify);
b.bundle().pipe(process.stdout);
Note that by default browserify-dustjs
transforms only .dust
and .html
files. You can add more extensions:
...
// transform `.dust`, `.html`, and `.tpl` files
b.transform(dustify.configure('.tpl'));
...
or specify all extensions:
...
// transform only `.dust` and `.tpl` files
b.transform(dustify.configure(['.dust', '.tpl']));
...
or both:
...
// transform only `.dust`, `.tpl`, and `.xyz` files
b.transform(dustify.configure(['.dust', '.tpl']).configure('.xyz'));
...