\Pluf_Template_Tag_Firstof

Template tag <code>firstof</code>.

Outputs the first variable passed that is not false, without escaping. Outputs nothing if all the passed variables are false.

Sample usage:

{firstof array($var1, $var2, $var3)}

This is equivalent to:

{if $var1} {$var1|safe} {elseif $var2} {$var2|safe} {elseif $var3} {$var3|safe} {/if}

You can also use a literal string as a fallback value in case all passed variables are false:

{firstof array($var1, $var2, $var3), "fallback value"}

Based on concepts from the Django firstof template tag.

Summary

Methods
Properties
Constants
__construct()
start()
No public properties found
No constants found
No protected methods found
$context
N/A
No private methods found
No private properties found
N/A

Properties

$context

$context : array

Type

array

Methods

__construct()

__construct(  $context = null) 

Constructor.

Parameters

$context

start()

start(  $tokens = array(), string  $fallback = null) 

Parameters

$tokens
string $fallback

Literal string to used when all passed variables are false.

Throws

\InvalidArgumentException

If no argument is provided.