Skip to content

Instantly share code, notes, and snippets.

@rek
Created September 4, 2014 06:26
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rek/f18a7e38b8e4e3686584 to your computer and use it in GitHub Desktop.
Save rek/f18a7e38b8e4e3686584 to your computer and use it in GitHub Desktop.
Dust.js Cheatsheet
{?cond}
cond is true
{:else}
cond is not true
{/cond}
{^cond}
cond is false
{:else}
cond is not false
{/cond}
{#loop}
<label>{something}{~n}
<option value="{value}" {@eq key=value value=courseName}selected="true"{/eq}>{label}</option>
</label>
{:else}
show if loop empty
{/loop}
{>partial_name /}
{>"flowViews/flowView{flowName}" /}
{@select key=\"{foo}\"}
{@eq value=\"bar\"}foobar{/eq}
{@eq value=\"baz\"}foobaz{/eq}
{@default} - default Text{/default}
{/select}
{@select key=foo}
{@gte value=5}foobar{/gte}
{/select}
{@if cond="{x} < {y} && {b} == {c} && '{e}'.length || '{f}'.length"}
<div> x is less than y and b == c and either e or f exists in the output </div>
{/if}
{@size key="xxx" }
My friends are:
{#friends}
{name}{@sep},{/sep}
{/friends}
The {@sep} helper tag will output it's body content unless this is the final iteration of the containing loop.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment