@Test public void t1() { Map<String, Object> attrs = new HashMap<>(4); attrs.put("a", 1); Conf conf = new Conf(); attrs.put("c", conf); attrs.put("b", Arrays.asList(1, 2, 3)); String template = "#{ if(a == 1) { } 1+2${a}x${a} #{ \\}}"; String result = engine.render(template, attrs); Assert.assertEquals(" 1+21x1 ", result); template = "#{ for(var it in b) { } ${b[it]} #{ \\}}"; result = engine.render(template, attrs); Assert.assertEquals(" 1 2 3 ", result); }
@Override public String render(String template, Map<String, Object> attrs) { StringWriter writer = new StringWriter(); render(template, attrs, writer); return writer.toString(); }
SimpleTemplateEngine implements TemplateEngine { @Override public String render(String template, Map<String, Object> attrs) { StringWriter writer = new StringWriter(); render(template, attrs, writer); return writer.toString(); } }
SimpleTemplateEngine implements TemplateEngine { @Override public String render(String template, Map<String, Object> attrs) { StringWriter writer = new StringWriter(); render(template, attrs, writer); return writer.toString(); }  }
SimpleTemplateEngine implements TemplateEngine { @Override public String render(String template, Map<String, Object> attrs) { StringWriter writer = new StringWriter(); render(template, attrs, writer); return writer.toString(); }  @Override String render(String template, Map<String, Object> attrs); @Override void render(String template, Map<String, Object> attrs, Writer writer); }
SimpleTemplateEngine implements TemplateEngine { @Override public String render(String template, Map<String, Object> attrs) { StringWriter writer = new StringWriter(); render(template, attrs, writer); return writer.toString(); }  @Override String render(String template, Map<String, Object> attrs); @Override void render(String template, Map<String, Object> attrs, Writer writer);  }