EndsWith ViewHelper <f:endsWith>
Note
This reference is part of the documentation of Fluid Standalone. If you are working with Fluid in TYPO3 CMS, please refer to TYPO3's ViewHelper reference instead.
EndsWith ViewHelper checks if the subject string ends with a specified string. This ViewHelper implements an if/else condition.
Examples
Render the body if "myString" ends with "World!"
<f:variable name="myString" value="Hello, World!" />
<f:endsWith search="Hello" subject="{myString}">This will be rendered if variable "myString" ends with "World!"</f:endsWith>
Copied!
Output:
This will be rendered if variable "myString" ends with "World!"
Copied!
A more complex example with inline notation
<f:variable name="condition" value="{false}" />
<f:variable name="myString" value="Hello, World!" />
<f:if condition="{condition} || {f:endsWith(search: 'World!', subject: myString)}">
It Works!
</f:if>
Copied!
Output:
It Works!
Copied!
Go to the source code of this ViewHelper: EndsWithViewHelper.php (GitHub).
Arguments
The following arguments are available for the endsWith ViewHelper:
else
-
- Type
- mixed
Value to be returned if the condition if not met.
search
-
- Type
- string
- Required
- 1
String to search in subject at the beginning
subject
-
- Type
- string
- Required
- 1
String to search in
then
-
- Type
- mixed
Value to be returned if the condition if met.