Added in: v1.9.1
DeprecatedThis tag is deprecated, use render tag instead for better encapsulation.
Include a Template
Renders a partial template from the template roots.
{% include 'footer.liquid' %} |
When the extname option is set, the above .liquid
extension can be omitted and writes:
{% include 'footer' %} |
When a partial template is rendered by include
, the code inside it can access its parent’s variables but its parent cannot access variables defined inside a included template.
Passing Variables
Variables defined in parent’s scope can be passed to a the partial template by listing them as parameters on the include
tag:
{% assign my_variable = 'apples' %} |
The with
Parameter
A single object can be passed to a snippet by using the with...as
syntax:
{% assign featured_product = all_products['product_handle'] %} |
In the example above, the product
variable in the partial template will hold the value of featured_product
in the parent template.