friendica/friendica — pull request #43 by fabrixxm (2012-02-21 10:34:42+00:00)
Title: Add support for variable filters in template

Add the possibility to call php function with var value as argument in template, to modify var value before printing.

Example:

before:

file.php
$r = q("SELECT * FROM notify");
foreach($r as &$row){
$row['body'] = bbcode($row['body']);
}
$o = replace_macros($tpl, array(
'$items' => $r
));

file.tpl
{{ for $items as $i}} $i.body {{ endfor}}

now:

file.php
$r = q("SELECT * FROM notify");
$o = replace_macros($tpl, array(
'$items' => $r
));

file.tpl
{{ for $items as $i}} $i.body|bbcode {{ endfor}}

is possible to concatenate function calls:

$i.body|bbcode|strip_tags

Syntax is

$var[.index[.index...]][|func[|func...]]