Java - Mustache Template Replace

Java - Mustache Template Replace

 

String template = "Hello {{name}}";

HashMap<String, Object> scopes = new HashMap<String, Object> ();
scopes.put("name", "Pokemon");

StringWriter writer = new StringWriter();

MustacheFactory mf = new DefaultMustacheFactory();
Mustache mustache = mf.compile(new StringReader(template), "example");

mustache.execute(writer, scopes).flush();
String str = writer.toString();
writer.close();

System.out.println("template: " + template);
System.out.println("result: " + str);