Details
-
Type:
Improvement
-
Status:
Closed
-
Priority:
Major
-
Resolution: Won't Fix
-
Affects Version/s: 1.8.3
-
Fix Version/s: None
-
Component/s: Templating
-
Labels:None
-
Number of attachments :
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.
Pull request made.