google / escapevelocity

A subset reimplementation of Apache Velocity with a much simpler API.
Apache License 2.0
33 stars 11 forks source link

Make it an error to render `$foo` if it is null. #15

Closed copybara-service[bot] closed 3 years ago

copybara-service[bot] commented 3 years ago

Make it an error to render $foo if it is null.

More generally, never allow rendering a null value. This is consistent with Apache Velocity. Previously we rendered the string null.

Improve error messages throughout by showing the reference where they occurred. For example, if $foo is null in $foo.bar($baz), we previously said Cannot invoke bar on null value. Now we say In $foo.bar($baz), $foo is null.

Add tests for many previously-untested error cases.

Implement the undocumented Velocity feature whereby $list[-1] means the last element of $list, which I discovered when writing the tests.