Skip to content

render

Renders a snippet by the given name.

Inside snippets, you can't directly access variables that are created outside of the snippet. However, you can specify variables as parameters to pass outside variables to snippets.

liquid
{% render 'snippet_name' %}

Render tag parameters

for

You can render a snippet for every item in an array using the for parameter. You can also supply an optional as parameter to be able to reference the current item in the iteration inside the snippet. Additionally, you can access a forloop object for the loop inside the snippet.

liquid
{% render 'snippet_name' for array as item %}

Passing variables to a snippet

Variables that have been created outside of a snippet can be passed to a snippet as parameters on the render tag.

liquid
{% render 'snippet_name', variable: value %}

with

You can pass a single object to a snippet using the with parameter. You can also supply an optional as parameter to specify a custom name to reference the object inside the snippet.

liquid
{% render 'snippet_name' with object as name %}