2.7.16. Bind

This is a compilation stage instruction. It captures the part of the template (not its output!) between {bind} and {/bind} tags and allows to insert it later somewhere else. The snippet is still dynamic, so if you change the data to display between two insertions of the same snippet, they generate different output. The instruction takes one parameter:

Table 2.12. Bind: parameters

Bind: parameters
NameTypeRequired?Description
nameIdYesThe unique name of a captured snippet.

Example 2.63. Binding the template source

{bind=snippet}
<p>This is a text: {@variable1}</p>
{/bind}

{var=variable1; "Value 1"}

{* we will see "This is a text: Value 1" *}
{insert=snippet}

{@variable1 = "Another value"}
{* we will see "This is a text: Another value" *}
{insert=snippet}

Note that you may put often used snippets in the master template.