Rendered via Layout, section "Main":
Structures template from Singles.
Fluid allows a handful of structures to render
dynamic parts of templates. Each method is
uniquely suited for precise use cases:
* No difference between inline and tag argument syntax
With the exception of using quotes, which must still be escaped, there is no difference between the following
examples of syntax:
Valid section
Valid section
Valid section
Valid section
* Passing arguments in inline mode
The following line:
Tag: "Dynamic"
Is identical in behavior to:
Pass: "Dynamic"
Which can also be expressed as:
Pipe: "Dynamic"
Pipe, multiple levels: "Dynamic"
In other words, tag contents can be passed also in inline mode, using either the combined "->" operator or standard pipe "|".
* Loop
You can loop through arrays in two ways; as standard
arrays and using a grouping by key to create "chunks":
one two three
one:
one one
two:
two
* Optional sections
There are two main ways to get this behavior:
This section exists and is rendered: Valid section
Expects no output because section name is invalid:
And:
Dynamic section name: Dynamically suffixed section
Bad dynamic section name, expects fallback: Just a section
The same works for partials:
This section exists and is rendered: Valid section
Expects no output because section name is invalid:
And:
Dynamic section name: Dynamically suffixed section
Bad dynamic section name, expects fallback: Just a section
* Inline render with condition
Render statements can be written as inline
expressions and conditioned by a clause:
Will render: Just a section
Will render, clause reversed: Just a section
Will not render:
* Else-if
Fluid allows the `f:else` ViewHelper to also include
a condition clause that must be true for that `f:else`
to be rendered. Multiple `f:else` can then exist. The
else-if approach only works when using full tag mode.
This `f:else` was rendered
* Switch
Although Fluid allows both if-then-elseif-else as well
as dynamic section names which in practice should mean
you can completely avoid a `switch`-like control. But,
when you do need a switch, one can be implemented as:
- Matched switch
The value was "3"
- Unmatched switch
The unmatched value case triggered
- Nested switch
The value was "3"
The "b" nested switch case was triggered
# Sir's template is rendered above (2,375 bytes).