Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Express integration for the Dust template engine

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 example
Octocat-spinner-32 test
Octocat-spinner-32 .gitignore
Octocat-spinner-32 LICENSE.txt
Octocat-spinner-32 README.md
Octocat-spinner-32 TODO.md
Octocat-spinner-32 dust-x.js
Octocat-spinner-32 package.json
README.md

Dust Templates for Express

dust-x integrates Dust templates into Express.

Installation

Since dust-x is still experimental, it's not published to npm yet. To use it, clone the git repository into your project directly:

$ cd node_modules
$ git clone git://github.com/laurie71/dust-x.git

Usage

To use Dust templates in Express you need to register dust-x as the template engine:

app.js:

var express = require('express')
  , dustx = require('dust-x')
  , app = express.createServer()

app.configure(function() {
    app.register('.dust', dustx)
    app.set('view engine', 'dust')
    ...
})

You can then render Dust templates from your route handlers as normal:

app.js:

app.get('/', function(req, res) {
    res.render('index', { title: 'Express+Dust' })
})

Compatibility

Dust uses an asynchronous API for template rendering, which Express unfortunately doesn't support yet. To work around this, dust-x monkey-patches Express' view rendering to work asynchronously, which will break other rendering engines. You therefore can't mix Dust templates with Jade, EJS or other templates.

Express applications typically only use a single template engine, so this isn't normally a problem in practice. You do need to bear it in mind if you want to migrate existing templates from another view engine to Dust, though.

Support

If you have problems getting dust-x to work in your project, start by looking at the example application.

If you're still stuck, or if you think you've found a bug or limitation in dust-x, please create an issue describing the problem.

Alternatively, you can try asking on the Express users' mailing list. Note, though, that dust-x isn't an official component of Express.

License

dust-x is distributed under the MIT license; see the LICENSE file for details.

Something went wrong with that request. Please try again.