Skip to content

Instantly share code, notes, and snippets.

@aerykk
Last active April 26, 2016 14:28
Show Gist options
  • Save aerykk/ada567e1e92e6ca7d574bb4dd3212d06 to your computer and use it in GitHub Desktop.
Save aerykk/ada567e1e92e6ca7d574bb4dd3212d06 to your computer and use it in GitHub Desktop.
Dust.js component usage
<!-- Expose keys of the `accordion` object to the scope -->
{#accordion}
<div class="accordion-wrapper">
<!-- Output a component called `accordion` and pass it `items` + `class` -->
{@c-accordion items=items class="padding-top-small"}
<!-- Override the `footer` block -->
{:footer}
<!-- Iterate the `links` array and expose keys of each object -->
{#links}
<!-- Output a component called `link` and pass it a `class` -->
{@c-link class="padding-all-bottom"}
<!-- Use exposed variables `href`, `src` and `alt` -->
<a href="{href}">
<img src="{src}" alt="{alt}" />
</a>
{/c-link}
{/links}
{/c-accordion}
</div
{/accordion}
<!-- Check if this scope has a `banners` key -->
{?banners}
<div class="padding-bottom-small margin-top-small">
<!-- Iterate the `banners` array and expose each object's keys to the scope -->
{#banners}
<!-- Output a component called `banner` passing it the keys exposed to the scope -->
{@c-banner text=text image=image class="margin-bottom-md" /}
{/banners}
</div>
{/banners}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment