Hi. How can we help?

3 e. Rain - syntax

Rain Syntax

Taken directly from the Twig documentation, the Syntax is simply explained:

There are two main kinds of delimiters: {% ... %} and {{ ... }}. The first one is used to execute statements such as for-loops, the latter prints the result of an expression to the template.

IF statements

IF statements are quite simple on the platform, for example:

{% if page.title == 'Brands' %} These are our brands {% elseif page.title == 'Tags' %} These are our tags {% else %} You should check out our Brands and Tags! {% endif %}

FOR Loops

FOR loops are used throughout the system to loop through arrays

{% for category in shop.categories %}<li> {{ category.title }}</li>{% endfor %}

Commenting

You can leave comments throughout your code that won't show up on the front-end:

{# this is a comment #}

What's next?

Was this article helpful?

0 out of 0 found this helpful