google / escapevelocity

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

Improve handling of space-deletion before `#set`. #43

Closed copybara-service[bot] closed 1 year ago

copybara-service[bot] commented 1 year ago

Improve handling of space-deletion before #set.

Previously we deleted horizontal whitespace between a $reference and a following #set, and all whitespace between a #directive and a following #set. But this was wrong (meaning, not the way Apache Velocity does it). We should only ever delete horizontal whitespace before a #set, whether preceded by a $reference or a #directive. The confusion arose because a single newline is deleted after a #directive, and then what remains before the #set may indeed only be horizontal whitespace.

Also fix a bug in TemplateTest where the same VelocityEngine instance was being used for multiple compare calls in the same test method. That was not right, because macros defined in one call persisted until the next and were not overridden by definitions of the same name.

RELNOTES=A bug with space deletion before #set has been fixed, to be more like Apache Velocity.