0
dust-compiler -s controllers/inbox/views/inbox.dust -d    public/js/custom/inbox/messages.js

but i am getting error

 if (err) throw err;
               ^
Error: ENOTDIR, scandir 'C:\jbk\buy2gthr-master\controllers\inbox\views\inbox.dust'
    at Error (native)

i have inbox.dust file:

{>"../../../layout/layout"/}

 {<css-content}
 {/css-content}
 {<page-content}
 {/<page-content}
     <script id="entry-template" type="text/x-tmpl">
                  {title}
                    <ul>
                        {#data}
                        <li>{name}</li>{~n}
                        {/data}
                    </ul>
     </script>
**<div id="output"></div>**
 {/page-content}
 {<script-content}
 <script src='/js/custom/inbox/inbox.js'></script>
 <script src='https://cdnjs.cloudflare.com/ajax/libs/dustjs-linkedin/2.7.2/dust-full.js'></script>
  {/script-content}

and inbox.js file

$(document).ready(function () {
    var data = {
        "title": "Famous People", 
        "names" : [{ "name": "Larry" },{ "name": "Curly" },{ "name": "Moe" }]
    }

    var source   = $("#entry-template").html();
    var compiled = dust.compile(source, "intro");
    console.log(compiled);

    dust.loadSource(compiled);

    dust.render("intro", data, function(err, out) {
        if(err) console.log(err);
        else
        console.log(out);

        $("#output").html(out);
    });
});

still i am gettting

<div id="output"><ul></ul></div>
Interrobang
  • 16,984
  • 3
  • 55
  • 63
PREETAM YADAV
  • 184
  • 3
  • 8

1 Answers1

0

I'm not sure what dust compiler you're using, but just use dustc -- it comes with Dust.

You can read about all the dustc API options, but to precompile a single file you'd do something like

dustc controllers/inbox/views/inbox.dust --output=public/js/custom/inbox/messages.js

dustc compiles templates using absolute names instead of relative ones, because Dust is not filesystem-aware. Unless you've specifically set up your dust.onLoad function to handle relative paths, you'll want to make your includes look something like {> "inbox/messages" /}.

Interrobang
  • 16,984
  • 3
  • 55
  • 63
  • ..now i am using dustc and now i have a messages.dust file ,so using dustc **dustc controllers/inbox/views/messages.dust --output=public/js/custom/inbox/messages.js** ,and in main inbox.dust file i have included messages.js ,dust-core.js and main inbox.js ,so in main inbox.js by which name** i have to render to template** – PREETAM YADAV Jul 28 '15 at 04:35
  • dust.render('messages', data, function(err, out) { document.getElementById('output').textContent = out; ?? – PREETAM YADAV Jul 28 '15 at 04:41
  • You can either pass the `--name` option to set the name you want to use, or otherwise the default name is the entire path, `controllers/inbox/views/messages`. You can pass the `--pwd` option to adjust this option. Read the API reference linked above. – Interrobang Jul 28 '15 at 04:43
  • using dust.render('messages',data,callback)...i am getting error Error: **Template Not Found: messages** at load (https://cdnjs.cloudflare.com/ajax/libs/dustjs-linkedin/2.7.2/dust-full.js:189:29) at Object.dust.render (https://cdnjs.cloudflare.com/ajax/libs/dustjs-linkedin/2.7.2/dust-full.js:100:7) at http://localhost:3000/js/custom/inbox/inbox.js:65:6 – PREETAM YADAV Jul 28 '15 at 05:02
  • javascript files order 'script src='https://cdnjs.cloudflare.com/ajax/libs/dustjs-linkedin/2.7.2/dust-full.js'> ` – PREETAM YADAV Jul 28 '15 at 05:02