0.01
No commit activity in last 3 years
No release in over 3 years
Compile Dust templates in the Rails asset pipeline.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 1.2.9
>= 2.0.3
>= 0
 Project Readme

dust.js for the Rails asset pipeline

First of all! The credits goes to handlebars_assets we used this gem as a base for dust_assets. The dust_assets gem allows you to use dust.js templates within Rails applications.

dust.js

dust_assets right now comes with a packaged v0.3.0 of dust.js. Some work is being currently done in extracting dust.js source into a separate gem that could be used by other gems as well.

Installation

Load dust_assets in your Gemfile as part of the assets group

group :assets do
  gem 'handlebars_assets'
end

Then run 'bundle install'

Require dust.js in your Javascript manifest (i.e. application.js)

//= require dust

Precompiling

dust_assets also works when you are precompiling your assets. If you are deploying to Heroku, be sure to read the Rails guide and in your config/application.rb set:

config.assets.initialize_on_precompile = false

Your file extensions tell the asset pipeline how to process the file. Use .dust to compile the template with Dust. Combine it with .jst to add the compiled template to the JST global variable.

JST

sprockets ships with a simple JavaScript template wrapper called JST for use with the ejs and other gems.

dust_assets is compatible with JST. If you name your template files name.jst.dust, you will have access to your templates through the JST global just like your ejs templates.

A note about dust.js templates and the current implementation of dust_assets gem:

dust.js templates are asychronous so when using the compiled templates availables trough the JST object you must supply a callback along with the context in which the template will be evaluated, suppose you have a template in 'app/assets/javascripts/templates/hello.jst.dust' that looks like this:

  Hello {name}!

In your code do something like this (this example is taken from a real Spine.js application written in CoffeScript)

  JST['templates/hello.jst.dust'] name: "Aleksander", (out, err) ->
    @html out

In JavaScript should be something like this:

  JST['templates/hello.jst.dust']({ name: "Aleksander" }, function(out, err) {
    return this.html(out);
  });

Example Rails 3 application using ´dust_assets´:

You can go to dust_assests_example and
see some basic usage of dust_assets.

Thanks

Thank you Aleksander Williams (@akdubya) for dust.js.

Thank you Les Hill (@leshill) handlebars_assets

Thank you Charles Lowell (@cowboyd) for therubyracer and handlebars.rb.

Contributing

Once you've made your great commits

  1. Fork
  2. Create a topic branch - git checkout -b my_branch
  3. Push to your branch - git push origin my_branch
  4. Create a Pull Request from your branch
  5. That's it!

Authors

  • Anderson Sequera (@andersonsp)
  • Jose Narvaez (@goyox86)
  • Manuel Mujica (@evilsaurer)

Contributors

  • Your name here!