Details
-
Improvement
-
Status: Closed
-
Major
-
Resolution: Won't Fix
-
1.8.3
-
None
-
None
Description
See Testing for nonexistent properties in groovy templates from the Groovy User list.
SimpleTemplateEngine should evaluate ${notAlwaysAvailable == null} to true if the variable is missing from the template binding. Instead it throws: Exception in thread "main" groovy.lang.MissingPropertyException: No such property: notAlwaysAvailable for class: SimpleTemplateScript4.
An exception in this case is not very useful, and is inconsistent with most other template implementations such as: the Java Unified Expression Language; the Spring Expression Language; FreeMarker; Velocity; and Ant, Maven and Spring property substitution.
The binding.variables.contains("notAlwaysAvailable") workaround is overly verbose, as is having to implement your own binding or template engine.