antlr/stringtemplate4 — pull request #82 by danishdynamite (2014-04-17 14:35:54+00:00)
Title: Support for custom functions.

Here's a patch to support user-supplied custom functions.

To use it, one just registers the function name and implementation like this:

Interpreter.registerCustomFunction("myOwnFunctionName", new Interpreter.CustomFunction() {
public Object execute(Object arg) {
// return result of whatever this function is supposed to do
}
});

and then it can be called from a template the same way as the built-in functions.

I've seen many requesting such a feature and instead resorting to terribly hacks using a map and overridden getter. I think this is a much cleaner method and hope it'll be accepted.