I keep seeing exclamation points at the end of FreeMarker code in Magnolia code examples. For example:
${content.header!}
What is the exclamation point called and what does it do?
I keep seeing exclamation points at the end of FreeMarker code in Magnolia code examples. For example:
${content.header!}
What is the exclamation point called and what does it do?
The exclamation point is called a default value operator. It's used to set a default value when an interpolation (${...}
) returns null
. If no default value is set, it returns an empty string (""
).
${content.header!}
<#-- Returns "" if content.header is null -->
${content.header!"Example Header"}
<#-- Returns "Example Header" if content.header is null -->
See Dealing with missing variables for more info.
© 2022 - 2024 — McMap. All rights reserved.
javascript
. Will someone searching for a FreeMarker answer to this question find that interchange sufficient? – Tribunate