{variable}

{variable} – creates PHP code to echo a variable

Synopsis

Usage ( {variable} , {variable:h} , {variable:u} )

Description

creates PHP code to echo a variable, with optional modifier. Modifiers are

  • No Modifier - does htmlspecialchars($variable)
  • :h - echos without any change - eg. raw
  • :u - echos urlencode($variable)

by default variables are assumed to have calling scope, and are prefixed with $t->, however if they are inside a loop (foreach), then the variables created by the loop are added to the scope and the prefix is not added.

Accessing object variables can be done using a dot as separator: {object.property}, calling methods is identical: {object.method()}.

Example

setting an object variable

$this->a = "hello >>";
$template->outputObject($this);

Outputting the variable

{a}
{a:h}
{a:u}

Compiled template

<?php echo htmlspecialchars($t->a); ?>
<?php echo $t->a; ?>
<?php echo urlencode($t->a); ?>

Simple ouput example

hello &gt;&gt;
hello >>
hello+%3E%3
setRequired - sets the prefix of an element to a value.. (Previous) creates a PHP method call, and echos the results (Next)
Last updated: Sat, 30 Aug 2014 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report or add a note.
View this page in:

User Notes:

Note by: alan_k
Full list of modifiers:

:h - raw output - be carefull!
:u - urlencode()
:r - print_r()
:n - number_format using options['numberFormat']
:b - nl2br(htmlspecialchars())
:e - htmlentities()
NONE -htmlspecialchars()
:OTHER - uses plugin mechanism