Partials

Templates can include other templates, called partials, using the following syntax.

{>"partial_name"/}

This will include the code from partial_name.dust into your template. The .dust extension is optional in partial declarations.

Although not required, it's a good practice to store partials in their own folder, e.g. partials. This keeps things organized and makes it easy to distinguish partials from regular templates. Refer to the default theme's template folder for an example.

When partials are stored in their own folder, you must include the name of that folder in the partial declaration.

{>"partials/template_name"/}

Partial Context

Partials inherit the context they're included from. That is, all the data that's available to your template when a partial is included will be made available to the partial as well.

As expected, globals can be used just like in any other template.

Passing Additional Data

You can pass additional data to partials through attributes.

{>"partials/example" name="Bob" email="bob@example.com"/}

Those attributes can then be referenced in the partial like any other variable.

Name: {name}
Email: {email}

This example shows basic string values being passed in, but you can pass in variables and objects as well.