Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 49 lines (30 sloc) 1.316 kb
d5f0d79 @thefron Add README.markdown
thefron authored
1 # Dust-Rails
2
3 This gem adds the Dust template and a corresponding assets engine to the asset pipeline in Rails => 3.1 applications.
4
5 For detailed information about Dust, visit <http://akdubya.github.com/dustjs/>
6
7 ## Installing
8
9 Add the following line to your Gemfile:
10
11 gem 'dust-rails'
12
13 Update your bundle:
14
15 bundle install
16
17 ## Usage
18
2567171 @thefron Update README.markdown
thefron authored
19 Place individual Dust template file in their own file with `template_name.js.dust` extension:
d5f0d79 @thefron Add README.markdown
thefron authored
20
dc4080f @thefron Update README.markdown
thefron authored
21 ```javascript
2567171 @thefron Update README.markdown
thefron authored
22 /* app/assets/javascripts/dusts/demo.js.dust */
23
d5f0d79 @thefron Add README.markdown
thefron authored
24 Hello {name}! You have {count} new messages.
dc4080f @thefron Update README.markdown
thefron authored
25 ```
d5f0d79 @thefron Add README.markdown
thefron authored
26
2567171 @thefron Update README.markdown
thefron authored
27 Which will be compiled and rendered as:
28
29 ```javascript
5825e3e @thefron Update README.markdown
thefron authored
30 (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;})();
2567171 @thefron Update README.markdown
thefron authored
31 ```
32
33
d5f0d79 @thefron Add README.markdown
thefron authored
34 In your javascript files, require `dust-core` and your own template files.
2567171 @thefron Update README.markdown
thefron authored
35 I recommend you put all the template files under `assets/javascripts/dusts` and require using `require_tree` for easy use.
d5f0d79 @thefron Add README.markdown
thefron authored
36
dc4080f @thefron Update README.markdown
thefron authored
37 ```javascript
2567171 @thefron Update README.markdown
thefron authored
38 /* app/assets/javascripts/application.js */
39
40 //= require dust-core
41 //= require_tree ./dusts
42 ...
43 dust.render("demo", {name: "Fred", count: 10}, function(err, out) {
44 console.log(out);
45 });
dc4080f @thefron Update README.markdown
thefron authored
46 ```
d5f0d79 @thefron Add README.markdown
thefron authored
47
48 All done. Your template files will be compiled and registered.
Something went wrong with that request. Please try again.