Strings

Name Description Function arguments Usage
replaceAll Replace all occurrences of the input in the text replaceAll(myText, lookFor, replaceWith) {{ replaceAll “test-string-test” “test” “new” }}
replace Replace the input text occurrences the given amount of times replace(myText, lookFor, replaceWith, times) {{ replace “test-string-test” “test” “new” 1 }}
repeat Repeat the given string the input amount of times repeat(myText, times) {{ repeat “my-string” 10 }}
trimSpace Remove trailing spaces trimSpace(myText) {{ trimSpace " my-StRing " }}
containsStr Check if string contains substring containsStr(str, part) bool {{ containsStr “my-StRing” “my” }}
startsStr Check if string have prefix startsStr(str, prefix) bool {{ startsStr “my-StRing” “my” }}
endsStr Check if string have suffix endsStr(str, suffix) bool {{ endsStr “my-StRing” “ing” }}
toLower Convert all characters to lower case toLower(myText) {{ toLower “my-StRing” }}
toUpper Convert all characters to upper case toUpper(myText) {{ toUpper “my-StRing” }}
toTitle Convert the text to title case toTitle(myText) {{ toTitle “my-StRing” }}
split Convert a string to a string array split(myText, separator) {{ split “one,two” “,” }}
splitN Convert a string to a string array with max splits splitN(myText, separator, times) {{ split “one,two,three” “,” 1 }}
hash Hash encoding, supported types: md5, sha1, sha256, sha512 hash(str, type) string {{ hash “my-StRing” “sha256” }}
encode Basic encoding, supported types: base32, base64, hex encode(str, type) string {{ encode “my-StRing” “base64” }}
decode Basic decoding, supported types: base32, base64, hex decode(str, type) string {{ decode “my-StRing” “base64” }}
hmac HMAC encoding, supported types: md5, sha1, sha256, sha512 hmac(str, key, type) string {{ hmac “my-StRing” “sec-key” “sha256” }}
html encapsulates a known safe HTML document fragment html(htmlStr) string {{ html “
trusted html
” }}
htmlAttr encapsulates an HTML attribute from a trusted source htmlAttr(htmlAttrStr) string {{ htmlAttr `dir=“ltr”` }}
urlSrc encapsulates a known safe URL or URL substring urlSrc(urlStr) string {{ urlSrc “/trusted/url” }}
uuid generates UUID V4 uuid() string {{ uuid }}
transformToCp Converts UTF-8 string to the one of desired code page options transformToCp(source, codepage) string {{ transformToCp “¡¢£” “iso8859_1” }}

The functions that accept a single parameter can also be used with the pipe notation.

<p>{{ "my-StRing" | toLower | trimSpace }}</p>
<!-- Results in: "my-string" -->

Supported code pages for transformToCp

Code page
cp037
cp437
cp850
cp852
cp855
cp858
cp860
cp862
cp863
cp865
cp866
cp1047
iso8859_1
iso8859_2
iso8859_3
iso8859_4
iso8859_5
iso8859_6
iso8859_7
iso8859_8
iso8859_9
iso8859_10
iso8859_13
iso8859_14
iso8859_15
iso8859_16
koi8r
koi8u
macintosh
macintoshcyrillic
windows874
windows1250
windows1251
windows1252
windows1253
windows1254
windows1255
windows1256
windows1257
windows1258