Variable example
Variable example
{* all code between noparse tags is not compiled *} variable {noparse}{$variable}{/noparse} = {$variable}Variable assignment
assignment {$number=10} and print {$number}Operation with strings
{$variable . $number}{$number + 20}
Variable Modifiers
{$variable|substr:0,7}a modifier on string: {"hello world"|strtoupper}
Global variables
The variable is declared as global into the PHP {$GLOBALS.global_variable}Show all declared variables
To show all declared variable use {noparse}{$template_info}{/noparse}.{$template_info}
Constants
Constant
Constant: {#true#}Modier on constant as follow
Negation of false is true: {PHP_VERSION|round}Loop example
Simple loop example
-
{loop="week"}
- {$key} = {$value} {/loop}
Loop example with associative array
- ID _ Name _ Color {loop="user"}
- {$key}) - {$value.name|strtoupper} - {$value.color} {/loop}
Loop an empty array
-
{loop="empty_array"}
- {$key}) - {$value.name} - {$value.color} {else} The array is empty {/loop}
If Example
simple if example
{if="$number==10"}OK! {else}NO!{/if}example of if, elseif, else example
{if="substr($variable,0,1)=='A'"}First character is A {elseif="substr($variable,0,1)=='B'"}First character is B {else}First character of variable is not A neither B {/if}use of ? : operator (number==10?'OK!':'no')
You can also use the ? operator instead of if {$number==10? 'OK!' : 'no'}Include Example
Example of include file
{include="test"}Functions
Example of function: ucfirst(strtolower($title))
{function="ucfirst(strtolower($title))"}Path Replace (WYSIWYG)
WYSIWYG
RainTPL replaces relative paths of images, css and links automatically with the correct server paths.Path replace on relative path of image
into the template the image is wrote as:<img src="img/logo.gif" alt="logo"/>
in the compiled template the path is replaced with the correct path tpl/img/logo.gif:
RainTpl is javascript friendly Absolute paths and path ending with # are not replaced
For more info read the documentation: http://www.raintpl.com/Documentation/Documentation-for-web-designers/WYSIWYG/