Apache Velocity: Is there a standard way of verifying the correctness of a template from the command line?

前端 未结 3 814
忘了有多久
忘了有多久 2021-01-05 13:50

Our website uses the Apache Velocity template language. Our Content Management System already checks any generated XML documents for well-formedness. We\'ve been asked to

3条回答
  •  [愿得一人]
    2021-01-05 14:32

    To catch Velocity syntax errors, your approach is probably the best.

    However, it will ignore invalid macro arguments and non-existent references. In Velocity 1.6 there is a strict mode that you can set which will throw an exception for bad macro parameters (e.g. the wrong number) or for bad references (e.g. $abc.badMethod() ). This assumes you are populating the context of the templates used in your testing tool the same as when the templates are used in production.

提交回复
热议问题