Search code examples
javavelocitytemplate-engine

Configure Velocity to fail on undefined $variable


Can Velocity be configure to fail (i.e. throw an Exception) when a $var is undefined.

Such a "fail-fast" strategy would help in our testing cycles.


Solution

  • In Velocity 1.6 you can add the following property to your velocity.properties

    runtime.references.strict = true

    Edit: Full list of configuration is available here: http://velocity.apache.org/engine/devel/configuration.html