Is it possible to replace multiple values in a FreeMarker template? For example, if I want to replace "a" and "b" with "c", I have to do this:
${event.EventTitle?replace('a','c')?replace('b','c')}
but I'd rather do something like this:
${event.EventTitle?replace("'a','b'",'c')}
Any chance FreeMarker has this capability?
I'm ultimately trying to replace all special characters ($,.,@,&,etc) with dashes, so feel free to suggest an easier way to do that.
Arithmetical calculations So the operators are: Addition: + Subtraction: - Multiplication: *
esc creates a markup output value out of a string value by escaping all special characters in it.
The string converted to boolean value. The string must be true or false (case sensitive!), or must be in the format specified by the boolean_format setting. If the string is not in the appropriate format, an error will abort template processing when you try to access this built-in.
The has_content FunctionFreeMarker has built-in functions to detect for variables. The most common method of detecting for empty or null values uses the has_content function and the trim function. The has_content function is often used with another built-in FreeMarker function to detect for null values.
You could use a regular expression for this:
${event.EnventTitle?replace('a|b', 'c', 'r')}
Note the 'r'
at the end.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With