Freemarker syntax has some reserved characters like other programming languages. This will cause unnecessary debugging when you find errors happening without reasons. So, one of the checks you need to do is to check for reserved characters in your variable naming.
Reserved Characters to Note
These are the reserved characters you must take note in your naming of variables.
How can I use variable names (macro name, parameter name) that contain minus sign (Source: Freemarker FAQ
-), colon (
:), dot (
.), or or other special characters?
Freemarker will not read the variable correctly if there is a special characters like “events-id”. You will be getting errors for Freemarker even if your syntax is correct.
How to Fix
These are some recommended solutions to fix them.
- Remove the special characters.
- Escape the characters with slash. “events\-id”.
- Enclosed the variables with square brackets [“events-id”]
- Assign the variables to your local variable name.
Freemarker is fussy with some of the reserved characters in variables naming. You need to take care not to include this when you name your variables. The easiest solution is to change the variable name. If the variable name cannot be changed, it is recommended to try other solutions to fix the name. My preferred solution will be assignment of the variable to my local variable name is the next best choice.