Skip to the content
Documentation
Help Start
Reading in:
  • German: 9,059 of 9,059 pages
About the help in other languages
All help pages

TPL syntax basics

The rules of the template language in one page: tags in braces, variables with $, values (strings, numbers, arrays, hashes, booleans), operators with pipe or call syntax, functions with parameters, comments, whitespace…

Download as PDF

Address: https://doc.exponential.earth/exphelp/viewer/help/designers/templates/tpl-syntax-basics.md

On this page

TPL syntax basics

This page is for designers who read or write templates. It lists the rules of the template language once, so the other pages can be short.

Contents

  1. Text and tags
  2. Values
  3. Variables
  4. Operators
  5. Functions
  6. Comments
  7. Braces in the output

Text and tags

Everything outside braces is printed as it is. Everything inside { } is a template tag:

TagMeaning
{$variable}print a value
{$value|operator}print a value passed through operators
{function param=value} ... {/function}a function with a body
{function param=value}a function without a body
{* ... *}a comment, never printed

Values

KindWritten as
string'single' or "double" quotes
integer, float42, 3.5
booleantrue(), false() (operators, written with parentheses)
arrayarray( 'a', 'b', 'c' )
hashhash( 'key', 'value', 'other', 2 )
test for nothing$value|null (true when the value is null), is_set( $value )

Variables

Variables start with $. They are created with {def}, changed with {set}, removed with {undef} (Variables and def). Attributes of objects and keys of hashes are read with a dot: $node.name, $node.data_map.title, $hash.key; array items with a number: $list.0 (Attributes and dot notation).

Operators

Two equivalent ways to call an operator:

{$text|upcase}                {* pipe: the value on the left is the input *}
{upcase( $text )}             {* call *}
{$text|shorten( 80 )}         {* pipe with parameters *}
{concat( 'a', $b, 'c' )}      {* call with several values *}

Operators can be chained: {$text|strip_tags|shorten( 120 )|wash}. Comparison and arithmetic are operators too: eq( $a, 1 ), gt( $count, 10 ), sum( $a, 2 ) (Operators overview).

Functions

Functions control the template: {if}, {foreach}, {def}, {include}, {cache-block}. Parameters are name=value pairs or, for some functions, a fixed syntax:

{include uri='design:parts/teaser.tpl' node=$child}
{foreach $items as $item} ... {/foreach}

See the Function reference.

Comments

{* A comment: may span several lines, never reaches the browser. *}

Use template comments, not HTML comments (<!-- -->), for notes about the template: HTML comments are sent to every visitor.

Braces in the output

A literal { or } in the output (CSS or JavaScript inside a template, which designs avoid anyway) is written as {ldelim} and {rdelim}, or the text is wrapped in {literal} ... {/literal} (Literal and delimiters).

Become an Exponential Partner

Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.

Something wrong on this page? Report an error

Documentation license

This documentation is free documentation, licensed under the GNU Free Documentation License 1.3 or later.

Exponential Copyright © 1998-2026 Exponential Foundation and 7x