{* This is a comment *}
Test Rain Tpl {$version}
Variables
Variable: {$variable}
Init Variable {$v = 10}
Show Variable {$v}
Modifier {$variable|strlen}
Cascade Modifier {$variable|substr:2,5|strlen}
Scoping (object) {$user->name}
Scoping (array) {$week.0}
Variable as key {$week[$numbers.0]}
Var test {$variable}
Ternary Operator
The title is: {isset($title)?"$title":'default title'}
Loop
Simple Loop
{loop="$week"}
-
{$key} {$value}
{/loop}
Modifier on Loop
{loop="$week|array_reverse" as $i}
- {$i}
{/loop}
Simple Nested Loop
{loop="$table"}
-
{loop="$value"}
{$value},
{/loop}
{/loop}
Loop on created array
{loop="range(5,10)" as $i}
- {$i}
{/loop}
If
True condition: {if="true"}This is true{/if}
Modifier inside if: {if="$variable|is_string"}True{/if}
Function test
Simple function: {function="time"}
Function with parameters: {function="date('d-m-Y')"}
Static method: {function="Test::method('123test')"}
Escape Text
Malicious content: {$bad_text}
Custom tag
{@message to translate@}
Custom tag 2
{%message to translate|english%}
Escape variable
{$bad_variable}
{autoescape="off"}{$safe_variable}{/autoescape}