Multiple applies on handlebars template

118 Views Asked by At

I have helpers that return a string that contains helperbars expressions. What I would like to achieve is that the expressions returned will also be resolved (and so on). It can be done quite easily without handlebars internal support by simply doing compileInLine on the result until the string returned doesn't change anymore.

Was wondering if there is some kind of configuration or better way to achieve it?

I need to use it in Java but my question applies both for handlebars.js and the jknack/handlebars project.

1

There are 1 best solutions below

0
Alkanshel On
Map<String, String> model = Map.of("first", "pie", "second", "cake");
Template template = handlebars.compileInline("{{first}} {{second}}!");
System.out.println(template.apply(model));

This should print "pie cake"