Skip to content

tbranyen/dustify-with-helpers

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NPM version

dustify

Browserify plugin to convert Dust.js templates to Javascript. This is a distant fork of dustjs-browserify.

Supports dust partials in the browser

This module performs static analysis to detect and browserify templates included using the dust partials syntax. If your script includes a template with a partial:

<p>hello</p>
{>"some/template"/}

Installation

npm install dustify

Example using callbacks

{
  ...
  "browserify": {
    "transform": [
      ["dustify", {"path": "lib/templates"}]
    ]
  }
}
var template = require('./template.dust');

template({ foo : 42 }, function (err, html) {
  if (err) { ... }
  ...
});

Example using a promise library

Please note that dustify does not install any promise library of its own. It's expected that you install it yourself.

{
  ...
  "browserify": {
    "transform": [
      [
        "dustify",
        {
          "path"     : "lib/templates",
          "promises" : "bluebird"
        }
      ]
    ]
  },
  ...
  "dependencies": {
    "bluebird": "*"
  }
}

You can also use ES6 promises provided by the browser:

{
  ...
  "browserify": {
    "transform": [
      [
        "dustify",
        {
          "path"     : "lib/templates",
          "promises" : true
        }
      ]
    ]
  }
}
var template = require('./template.dust');

template({ foo : 42 })
  .then(function (html) {
    ...
  })
  .catch(function (error) {
    ...
  });

Both of these examples will work on the server and in the browser.

Dust.js documentation

Security

License

MIT

About

Browserify plugin to convert dustjs (with helpers) templates to Javascript.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%