1

I am new to Dust.js and I have just gone thru "the only" complete tutorial I am able to find on the internet (https://github.com/linkedin/dustjs/wiki/Dust-Tutorial). Now, I have some understanding on it, try to experiment around to get better understanding.

From my understanding, we can put the template on the main page so it will look something like this:

<script type="text/x-template" id="itemTemplate">
    {company}
    {#employees}
       <div> Name: {name}</div>
    {/employees}
</script>

I tried putting the content into mytemplate.tl and load it from script.

<script type="text/x-template" id="itemTemplate" src="template/mytemplate.tl"></script>

But it did work. How can I put that template externally?

Thank you.

user1995781
  • 19,085
  • 45
  • 135
  • 236
  • even i need the same help... i went through all the resources i can... no success :( also in the dust download example of browser-basic > files are missing "compiled.js" & thats the file that i assume to have compilation of external templates. – saurabh Apr 14 '15 at 03:41

1 Answers1

0

There is a pretty decent example here: Basic Example of Client Side Templating with Dust.js. Ideally you would compile the template to JS before sending it to the client as that would be faster on the client-side but for playing around, compiling it on the client is easier.

Community
  • 1
  • 1
rragan
  • 484
  • 2
  • 2
  • Hi, Thanks for your answer. But how to compile the template to JS? If it is compiled, does it still work with dynamic JSON data? – user1995781 Jun 21 '14 at 06:46