Functions
In hop, functions are defined using the <function>
tag and rendered using the <render>
tag.
Defining a function
The <function>
tag is used to define a new function.
html
<function name="foo" params-as="items">
<for each="items" as="item">
<div></div>
</for>
</function>
Attributes | Use |
---|---|
name="…" | Specifies the name of the function. |
params-as="…" | Introduces a variable that holds the data that is passed in when the function is rendered. |
Rendering a function
The <render>
tag is used to render a function.
html
<render function="foo" params="items"/>
Attributes | Use |
---|---|
function="…" | Specifies the name of the function that should be rendered. |
params="…" | Specifies which variable to use as the data passed to the function. |