Tag include

The simplest modular construct in Jtwig is the include construct. By using this construct one can include another template.

{% include pathExpression ignore missing with {} only %}

The pathExpression can be any expression that, once evaluated will then be used by the resource resolution mechanism in order to retrieve another Jtwig template. The previous example shows all include possible arguments. In this section one will describe all arguments in detail.

ignore missing (optional)

If Jtwig resource resolution is not able to find the given resource, include will, by default, throw an error. When the argument ignore missing is set, Jtwig will ignore missing resources and proceed with the rendering.

{% include templatePath ignore missing %}

with (optional)

The with argument adds the capability to provide model variables to the included template. The expression is expected to be evaluated as a map.

{% include templatePath with { key: 'value' } %}

only (optional)

The only argument tells the engine to isolate the included template from the parent context. That way variables currently defined in the context won't be visible in the included template. Only the model defined within the with map expression will be available, if provided.

{% include templatePath with { key: 'value' } only %}