I'm looking for a nice template engine or short piece of code to expand Ant-like variables in a string in Java. Example:
String result = expand ("${firstName} ${familyName}", map);
It should at least support java.util.Map
but something that can handle beans or recursive lookups or lookups in a list of maps/objects would be welcome, too.
Suggestions?
[EDIT] In reply to TofuBeer: No nesting, only valid Java identifiers within the {}
. Anything outside of ${}
should be copied verbatim. $$
should become $``. If that's not possible ${dollar}
should expand to a single $
(so you can express 15.00 $
).