linkedin / dustjs

Asynchronous Javascript templating for the browser and server
http://dustjs.com
MIT License
2.91k stars 479 forks source link

@eq not rendering in browser #446

Closed dhritzkiv closed 10 years ago

dhritzkiv commented 10 years ago

I have template code that I've dumbed down to:

{@eq key="yes" value="yes"}
    yes
{:else}
    no
{/eq}

When I render it server side (using consolidate), it gives me the expected value of yes. However, when I try to render in the browser (with a server-side compiled .js file), I don't see either bodies rendered.

Here is the compiled js code:

(function(){dust.register("_eq-test",body_0);function body_0(chk,ctx){return chk.helper("eq",ctx,{"else":body_1,"block":body_2},{"key":"yes","value":"yes"});}function body_1(chk,ctx){return chk.write("no");}function body_2(chk,ctx){return chk.write("yes");}return body_0;})();

Most everything else renders fine. Am I missing a step? Am I doing something wrong?

Using 2.3.4

kate2753 commented 10 years ago

@dhritzkiv do you have dustjs-helpers included on your page when rendering in browser? Dustjs-helpers provides the @eq helper, without it dust doesn't know how to handle {@eq and will render empty string instead.

You can get dustjs-helpers here https://github.com/linkedin/dustjs-helpers

dhritzkiv commented 10 years ago

Oh thank you for catching that. I forgot to include that in my page. Feeling quite silly now. Closing