### Question:
TemplateUtils { public String process(String template, JsonNode value) { final Context ctx = new Context(); List<String> fields = getVariables(template); for (String field : fields) { if (value.get(field) != null) ctx.setVariable(field, value.get(field).asText()); else ctx.setVariable(field, "[empty]"); } return stringTemplateEngine.process(template, ctx); } private  TemplateUtils(); static TemplateUtils getInstance(); String process(String template, JsonNode value); String process(String template, Map values);  }### Answer:
@Test public void astext() { StringTemplateResolver templateResolver = new StringTemplateResolver(); templateResolver.setOrder(1); templateResolver.setTemplateMode(TemplateMode.TEXT); templateResolver.setCacheable(false); TemplateEngine templateEngine = new TemplateEngine(); templateEngine.setTemplateResolver(templateResolver); Context context = new Context(); context.setVariable("mavar","cela"); String process = templateEngine.process("ceci [[${mavar}]]", context); assertThat(process).isEqualTo("ceci cela"); String notInterpreted = templateEngine.process("ceci <span th:text=\"${mavar}\"></span>", context); assertThat(notInterpreted).isEqualTo("ceci <span th:text=\"${mavar}\"></span>"); }
@Test public void ashtml() { StringTemplateResolver templateResolver = new StringTemplateResolver(); templateResolver.setOrder(1); templateResolver.setTemplateMode(TemplateMode.HTML); templateResolver.setCacheable(false); TemplateEngine templateEngine = new TemplateEngine(); templateEngine.setTemplateResolver(templateResolver); Context context = new Context(); context.setVariable("mavar","cela"); String process = templateEngine.process("ceci [[${mavar}]]", context); assertThat(process).isEqualTo("ceci cela"); String variant = templateEngine.process("ceci <span th:text=\"${mavar}\"></span>", context); assertThat(variant).isEqualTo("ceci <span>cela</span>"); }