Skip to main content

Block

Video tutorial

General information about blocks

A block contains programming code and can also contain comments. For the compiler to process programming code, this code needs to be contained in a statement block. Blocks are inserted directly into existing templates. A block can wrap one or several lines of code. The structure of both variations is described below.

Structure of single-line code blocks

A block is introduced by a left brace ({) followed by a percentage sign (%). The end of a block is defined using a percentage sign (%) followed by a right brace (}).

{% $_foo = "hello world" %}

Structure of multi-line code blocks

Multi-line code blocks are also wrapped by braces and percentage signs ({% …​ %}). However, a multi-line block contains more than one statement. These statements are not separated by the beginning and end of a block. Instead, the individual statements of multi-line blocks are separated by a semicolon (;). if statements are wrapped by braces ({ }).

{%
	if($_a > $_b)
	{
		print("a is greater than b");
	}
%}

Raw blocks

The parser does not check and translate the content of raw blocks. They are displayed in their raw format. Raw blocks need to have a start tag {% raw %} and an end tag {% endraw %}.

{% if $Producer %}
	<dt>Manufacturer</dt>
	<dd>$Producer</dd>
{% endif %}



{% raw %}
	{% if $Producer %}
		<dt>Manufacturer</dt>
		<dd>$Producer</dd>
	{% endif %}
{% endraw %}

Sections

Programming code can be used in web design templates, categories and email templates. Programming code that is inserted outside of a block will not be processed but printed instead.

To top