Include-if-exists Tag
Renders a view if it exists.
Overview#
You can use this tag to output a view if it exists. If the view doesn't exist, nothing is output instead of throwing a "view not found" exception. Useful if you have some sort of dynamic loop.
{{ include:if_exists src="myview" }}
<s:include:if_exists src="myview" />
This tag accepts everything the include tag does, including slots and the same scope rules.
Related Reading#
This tag goes hand in hand with the include tag.
You may be interested in the include:exists tag if you need to do a more complicated conditional check in your template.
Parameters
src
The name of the view to render. Example: src="cards/author_bio" or :src="var_name".
when
Render the view only if a condition is met.
unless
The converse of when.
cascade
When true, the Cascade is made available inside the view. Defaults to false.
params
An associative array whose entries become variables in the view. Any parameter you set directly on the tag overrides a matching key.
handle_prefix
A prefix, or array of prefixes, to strip from the keys in params. With handle_prefix="hero_", a hero_title entry is also available as {{ title }}.
*
Any other parameter you create will be passed through to the view as a variable.