Reputation: 11173
I'm using Freemarker 2.3.20 with JDK 7.
When ever I'm defining a value in my template that results in NULL at run time, it gives me an error. I understand there are many ways to handle this error as mentioned in answers like this one: Simulate null parameters in Freemarker macros
But what I want is a global solution. My freemarker template has 'hundreds' of fields that any of them could be null at any given time. Instead of writing a function to call to handle for nulls, or setting a default value for null with the exclamation mark '!', etc; Is there a way to define something global in the freemarker configurations, or overwrite some java class, such that: all null fields will return 'NULL' or a particular user defined value.
Upvotes: 3
Views: 5381
Reputation: 27
You can add <#setting classic_compatible=true>
in .ftl file or add
Configuration cfg = new Configuration(); cfg.setClassicCompatible(true);
in your code.
Upvotes: 1