Actually... I've just found another one: https://github.com/PebbleTemplates/pebble
This uses the exact same template format as JTwig, has a nicer API by the looks of it, is actively maintained, and has three times as many stars on github. Probably lacks the HTML escaping issues I've had with JTwig, too.
I've just tried using macros in JTwig and it incorrectly caches the effect of the {%import ...%} statement.
And one more thing: this Pebble has only TWO!!1 runtime dependencies, one of which is SLF4J.
And also...
- It supports named parameters in functions/filters/macros
- It can render templates to a stream (also TIL that I can stream responses to the browser via ServletResponse, available from Spark's Response via .raw())
- You can make custom tags and even operators, custom EVERYTHING
- Did I tell you that the API is nicer than that of JTwig?
- There's a range function so you can have a for loop without an array or a map!
- You can have {%else%} in {%for ...%} to handle an empty list