Regular expression extract
TheregexExtract helper supports extraction of values matching a regular expresson from a string.
A single value can be extracted like this:
String transformation helpers
Trim
Use thetrim helper to remove whitespace from the start and end of the input:
Abbreviate
abbreviate truncates a string if it is longer than the specified number of characters.
Truncated strings will end with a translatable ellipsis sequence (”…”).
For instance the following template:
Capitalisation
capitalize will make the first letter of each word in the passed string a capital e.g.
capitalizeFirst will capitalise the first character of the value passed e.g.
Center
center centers the value in a field of a given width e.g.
Cut
cut removes all instances of the parameter from the given string.
Default if empty
defaultIfEmpty outputs the passed value if it is not empty, or the default otherwise e.g.
Join
join takes a set of parameters or a collection and builds a single string, with
each item separated by the specified parameter.
Justify left and right
ljust left-aligns the value in a field of a given width, optionally taking a padding character.
rjust right-aligns the value in the same manner
Lower and upper case
lower and upper convert the value to all lowercase and all uppercase:
Replace
replace replaces all occurrences of the specified substring with the replacement value.
Slugify
slugify converts to lowercase, removes non-word characters (alphanumerics and
underscores) and converts spaces to hyphens. Also strips leading and trailing whitespace.
Strip tags
stripTags strips all [X]HTML tags.
Substring
substring outputs the portion of a string value between two indices. If only
one index is specified the substring between this point and the end will be returned.
Word wrap
wordWrap wraps words at specified line length.
Yes/no
yesno maps values for true, false and optionally null, to the strings “yes”,
“no”, “maybe”.