Variables are the dynamic contents of the template, valorized in the execution of the script with RainTPL assign() method.
Variable names are case sensitive.
Example:
Output:
Operation with variables
You can use arithmetic operators for simple operations: +, -, *, /, %, .
Example:
{$num + 10}
<!-- $a value is 1, $b value is 2 -->
{$a + $b}
Output:
3
Initialize a variable
Also if should be done in the PHP layer, is possible to initialize a variable value with the = operator:
Example:
{$var="Hello world!"}
Arrays and objects
Variables can be either one-dimensional (strings, numbers, boolean values) and multidimensional (arrays, objects).
To access array values use the dot operator "." and to access object values use the arrow operator "->".
To access array use the {loop} tag.
Example:
Array :
- website =>
-
- name => Rain
- url => http://www.raincms.com
Template:
Output:
Global Variables
You can use {$GLOBALS} into template to access globals value.
Template:
Show all assigned variables
You can use the special variable {$template_info} to see all the variables assigned to your template
Template:
