dust-named-loader

dustjs loader module for webpack, with support for naming the template

Usage no npm install needed!

<script type="module">
  import dustNamedLoader from 'https://cdn.skypack.dev/dust-named-loader';
</script>

README

dust loader for webpack (with names)

Compiles dust templates and exports the compiled functions, allowing for rendering of the templates in a browser environment.

Usage

Documentation: Using loaders

var template = require("dust-named-loader!./file.dust");
// => returns file.dust compiled as template function

Recommended config

module.exports = {
  module: {
    loaders: [
      { test: /\.dust$/, loader: "dust-loader" }
    ]
  }
};

Then you only need to write: require("./file.dust")

Rendering a template

You will need to bundle the dust core in your pack in order to render the compiled templates.

require('dust-named-loader?name=myTemplate!./views/foo/bar.tpl');

dust.render('myTemplate', context, function(err, result){
    // result holds the rendered HTML code
});

License

MIT (http://www.opensource.org/licenses/mit-license.php)