A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/scottbrady/dustjs-browserify below:

scottbrady/dustjs-browserify: Browserify plugin to convert dustjs templates to Javascript.

Browserify plugin to convert dustjs templates to Javascript.

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>p>
{>"some/template"/}

The dustjs-browserify module will also include and browserify the some/template.dust template.

This package is available on npm as:

npm install dustjs-browserify
Browserify config example
transform: [
  [
    {
      path    : 'lib/templates'
      promise : true
    },
    'dustjs-browserify'
  ]
]

This module is most useful when you're also using the dustjs-loader module.

Example using a callback:

require('dustjs-loader').register({
  path: 'lib/templates'
});

var template = require('./template.dust');

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

Example using a promise:

require('dustjs-loader').register({
   path    : 'lib/templates',
   promise : 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.

MIT


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4