Skip to content
shopdepot.dev

Reference

Tags

Twig tags allowed in theme files, and the theme tags for schemas, styles, scripts and documentation.

View as Markdown

Generated from the platform code - always matches what the theme engine allows.

Tags are logic: {% if %}, {% for %}. Everything that is not listed - extends, block, macro, import, use, sandbox, deprecated and the rest - is refused by the sandbox.

Theme

schema

The JSON schema of a section or block - its name, settings, nested blocks and presets. Required in a block, forbidden in a snippet. It never renders.

{% schema %} { … } {% endschema %}

stylesheet

CSS of a section or block. The platform collects every stylesheet of the theme into one file (_sections.css) linked in content_for_header, so the CSS loads once however many times the section appears.

{% stylesheet %} … {% endstylesheet %}

javascript

JavaScript of a section or block, collected into _sections.js the same way as stylesheets. The platform does not link that file for you - prefer a module in assets/, or add {{ '_sections.js'|asset_url|script_tag }} to the layout.

{% javascript %} … {% endjavascript %}

doc

Documentation of a snippet or block - its parameters. It never renders.

{% doc %} @param name - description {% enddoc %}

Twig tags

apply

Applies filters to a block of output.

{% apply upper %}…{% endapply %}

do

Evaluates an expression without printing it.

{% do expression %}

else

Part of if and for.

{% else %}

elseif

Part of if.

{% elseif condition %}

for

Loops, with loop.index, loop.first, loop.last; the else part runs for an empty list.

{% for item in list %}…{% else %}…{% endfor %}

if

Conditions.

{% if condition %}…{% elseif other %}…{% else %}…{% endif %}

set

Assigns a variable.

{% set name = value %}

verbatim

Outputs Twig syntax unparsed - for client-side templates.

{% verbatim %}…{% endverbatim %}

with

A scope with its own variables.

{% with { name: value } only %}…{% endwith %}