This tag loads and executes another template, but will never render any output. It's only purpose is for loading macros and setting some variables.
Name | Description |
---|---|
Tag Name | import |
End Tag | N/A |
Rendering | Immediately; no output |
Parameter | Description |
---|---|
Template | The name of the template you want to load. |
The template name will depend on how your environment's loader is configured:
- If you're using a file loader, template should be a valid file name.
- If you're using a dictionary loader, template should be a key in that dictionary.
Should be used when you have some macros or sets that you want to reuse in multiple templates.
Note that this tag may appear similar to the existing include tag, but the purposes are opposite of each other:
include
will render the included template, but never store changes to the context.import
will never render the imported template, but will store changes to the context.
{% import "common.stencil" %}
{% call test "a" "b" "c" %}
common.stencil
file:
{% macro test a b c %}
Received parameters in test:
- a = "{{a}}"
- b = "{{b}}"
- c = "{{c}}"
{% endmacro %}