dust:common
This is the common namespace, where the default components reside.
Table of Contents
Components
All of these components are located in the namespace dust:common
. All of these examples bind dust:common
to d
and dust:parameters
to p
.
if
Component that will output its content if a certain test passes. Will optionally output some content if the test does not match.
Example
<d:if test="${test}">
This will be emitted if the test passes.
<p:else>
This is an optional parameter that is rendered if the test does not pass.
</p:else>
</d:if>
Attributes and parameters
Name | Required | Type | Description |
---|---|---|---|
test | Yes | Boolean | The expression to test against. |
else | No | Parameter | Optional markup block to render if the test fails |
loop
Loop over certain values, outputting its content for every value.
Example
<d:loop source="${values}" value="${value}">
<div>${value}>/div>
</d:loop>
Attributes and parameters
Name | Required | Type | Description |
---|---|---|---|
source | Yes | Array, Iterable or Iterator | The source of values to loop over. |
value | Yes | * | The expression that is set for every value looped over |
body
Output content passed into the body of a component. Can optionally output the contents of a parameter.
Example
<d:body />
<d:body id="param" />
Attributes and parameters
Name | Required | Type | Description |
---|---|---|---|
id | No | String | Optional identifier of a parameter to output |
raw
Output some content without escaping it.
Example
<d:raw value="${someHtml}">
Attributes and parameters
Name | Required | Type | Description |
---|---|---|---|
value | Yes | * | Value to output |
holder
Wrap other markup and output it. Used to support components that do not have a single root element.
Example
<d:holder>
<td>Hello</td>
<td>Cookie</td>
</d:holder>
render
Render an object assuming it has a template or it is an instance of Emittable
.
Example
<d:render value="${object}" />
Attributes and parameters
Name | Required | Type | Description |
---|---|---|---|
value | Yes | * | Value to render |
Mixins
if
Only output the element if the test passes.
<div d:if="${test}">
Hello!
</div>
attributes
Mixin attributes used when calling the current component.
<button class="btn-lg" d:attributes="merge">${title}</button>
Expressions
urlencode(String)
Encode the given string for inclusion in a URL.
${d:urlencode(name)}
${name.d:urlencode()}
emit
and skip
These two properties are used together with attributes to output an empty attribute or skip an attribute.
<input type="checkbox" ... checked="${checked ? d:emit : d:skip}" />