Skip to content

Modifiers

pfaciana edited this page Sep 25, 2019 · 2 revisions

Variable modifiers can be applied to variables, functions or strings. To apply a modifier, specify the value followed by a | (pipe) and the modifier name. A modifier may accept additional parameters that affect its behavior. These parameters follow the modifier name and are separated by a : (colon). Also, all javascript functions can be used as modifiers implicitly and modifiers can be combined.

{$foo = 'bar'}

{$foo|upper}
{$foo|upper|replace:'B':'G'}
{'foobar'|upper}

{javascript}
    hello = function(to) {
        return 'Hello '+to+'!';
    }
{/javascript}

{hello('world')|upper}

output =>

BAR 
GAR 
FOOBAR 
HELLO WORLD!

Latte has some modifiers built in. Main documentation has list of modifiers available. Building custom modifiers using plugin is easy using Latte.

Clone this wiki locally