This is LinkedIn Dust JS wiki page that can answer your questions and has very good examples: http://linkedin.github.com/dustjs/
But to answer your questions here:
Yes you need to compile your dust template which becomes a JavaScript file that you can add to your page by <script>
tag and then call dust.render method to render your template. Here is an example:
write following code in a template file and save it as sample.tl
<p>Hi {firstName} {lastName}</p>
compile sample.tl to sample.js by
dustc sample.tl
in command line or usedust.compile("your_template_code", "template_name")
to compile the template and save the output in a JavaScript file (sample.js) or you use duster.js to watch and compile templates by nodejs: https://github.com/dmix/dusterjsadd sample.js in your html:
<script type="text/javascript" src="sample.js"></script>
this will also register your template to dust.cache.
in your JavaScript:
var your_json = {firstName:'James', lastName:'Smith'}; dust.render('sample', your_json, function(err, out){ your_dom_element.innerHTML = out; });
The result of above
dust.render
method will be<p>Hi James Smith</p>
So you need to pass 3 arguments to
dust.render
:dust.render(template_name, json, callback)