--- url: https://docs.youcan.shop/themes/tags/render.md --- # `render` Renders a snippet by the given name. ```liquid {% render 'snippet_name' %} ``` ## Variables Inside a snippet, you can read the variables of the template, section or snippet where the `render` tag is. Variables that you create in the snippet with `assign` or `capture` are kept inside the snippet. They are not visible after the `render` tag. The value of a variable with the same name outside the snippet is not changed. Pass every variable that you read in the snippet as a parameter. Then the snippet is rendered the same way from every template. For example, write `{% render 'card', product: product %}` instead of `{% render 'card' %}` inside a `for product in ...` loop. Use [`include`](/themes/tags/include) when you must change variables outside the snippet. # Render tag parameters ## `for` You can render a snippet for every item in an array with the `for` parameter. Inside the snippet, the current item has the name of the snippet, or the name you give with `as`. The snippet can also read a `forloop` object for the loop. ```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 with the `with` parameter. Inside the snippet, the object has the name of the snippet, or the name you give with `as`. ```liquid {% render 'snippet_name' with object as name %} ```