The template is created in Handlebars JS. and to process in Java jknack handlebars is used. I wrote helper class to assign value in a variable through enum syntax. I got inspiration from enum NumberHelper
and write my own enum VarHelper
. Here is the "Var" code
{{ var "$a" jsonObj }}
var {
@Override public CharSequence safeApply(final String variableName, final Options options) throws IOException {
System.out.println( options.params[0]); options.context.data(variableName, options.params[0]); return null;
}
};
I expect options.params[0]
value should be {name : john}
, but the actual output is {name=john}