TemplateFactory t = new TemplateFactory(new File(TestConfig.class.getResource("/page").toURI())).init();
// System.out.println(t.getConfig().getViewPath());
// System.out.println(t.getConfig().getCompiledPath());
View view = t.getView("/testIf.html");
ByteArrayOutputStream out = new ByteArrayOutputStream();
Model model = new ModelMock();
view.render(model, out);
out.close();
System.out.println(out.toString());
out = new ByteArrayOutputStream();
model.put("user", user);
model.put("login", true);
view.render(model, out);
out.close();
System.out.println(out.toString());
// #for
model = new ModelMock();
out = new ByteArrayOutputStream();
view = t.getView("/testFor.html");
List<User> list = new ArrayList<User>();
user = new User();
user.setName("Tom");
user.setAge(20);
list.add(user);
user = new User();
user.setName("小明");
user.setAge(13);
list.add(user);
user = new User();
user.setName("小红");
user.setAge(20);
list.add(user);
model.put("users", list);
model.put("intArr", new int[]{1,2,3,4,5});
view.render(model, out);
out.close();
System.out.println(out.toString());
// #switch #case #default
model = new ModelMock();
out = new ByteArrayOutputStream();
view = t.getView("/testSwitch.html");
model.put("stage", 2);
view.render(model, out);
out.close();
System.out.println(out.toString());
// #set
model = new ModelMock();
out = new ByteArrayOutputStream();
view = t.getView("/testSet.html");
model.put("name", "迈克");
view.render(model, out);
out.close();
System.out.println(out.toString());
// #include