Fluid Syntax: Variables
Accessing variables
Variables in Fluid can be accessed with the following braces {}
syntax:
<h1>{title}</h1>
Copied!
Arrays and objects
Use the dot character .
to access array keys:
<p>{data.0}, {data.1}</p>
Copied!
This also works for object properties:
<p>{product.name}: {product.price}</p>
Copied!
These object properties are obtained by evaluating a fallback chain,
which includes various getter methods as well as direct property access.
For example, the following PHP-equivalents would be checked for {product.
:
$product->getName()
$product->isName()
$product->hasName()
$product->name
Copied!
Also, both Array
and the PSR Container
are supported.
Dynamic keys/properties
It is possible to access array or object values by a dynamic index:
{myArray.{myIndex}}
Copied!
Reserved variable names
The following variable names are reserved and must not be used:
_all
true
false
null