Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…
Cannot retrieve contributors at this time
49 lines (30 sloc) 1.29 KB


This gem adds the Dust template and a corresponding assets engine to the asset pipeline in Rails => 3.1 applications.

For detailed information about Dust, visit


Add the following line to your Gemfile:

gem 'dust-rails'

Update your bundle:

bundle install


Place individual Dust template file in their own file with template_name.js.dust extension:

    /* app/assets/javascripts/dusts/demo.js.dust */

    Hello {name}! You have {count} new messages.

Which will be compiled and rendered as:

    (function(){dust.register("demo",body_0);function body_0(chk,ctx){return chk.write("Hello ").reference(ctx.get("name"),ctx,"h").write("! You have ").reference(ctx.get("count"),ctx,"h").write(" new messages.");}return body_0;})();

In your javascript files, require dust-core and your own template files. I recommend you put all the template files under assets/javascripts/dusts and require using require_tree for easy use.

    /* app/assets/javascripts/application.js */

    //= require dust-core
    //= require_tree ./dusts
    dust.render("demo", {name: "Fred", count: 10}, function(err, out) {

All done. Your template files will be compiled and registered.

Jump to Line
Something went wrong with that request. Please try again.