Handy dust.js template references
See dust.js page to start
Linkedin Dust page
Very helpful post
We've used many features including inheritance and substitution
Dynamic partials, very helpful to include partials based on values (avoids conditionals)
e.g. {>"partname-{aValue}"/}
This is use of if dust helper
{@if cond="'{choiceShown}' <= 0"}
<p class="choicesmessage" class="myStyle">Some text</p>
{/if}
One of reasons I like dust is that if avoids js code "logic-less" in the template. So it feels "wrong" to create an @if with its funky syntax as well as other kinds of helpers.
Need to be really careful with these. I'm very much with the "logic-less" school with regards to templates.
dust has a really useful lookup mechanism when looking for properties, see the 2nd link section "Traversing JSON using dust". We needed to show properties which were nested in a differrent block to the one being processed. That is possible using dust because when resolving blocks dust does "Dust does bottom up traversing from a section, not top down traversing"
This is very powerful because the dust data does not have to match exactly the view layout order.
Comments
Post a Comment