@Test public void test_render() throws Exception { String templateVariable = "Hello Jtwig!!"; Map<String, Object> model = new HashMap<>(); model.put("message", templateVariable); String expected = String.format("<h1>%s</h1>", templateVariable); String actual = new JtwigTemplateEngine().render(new ModelAndView(model, "hello.twig")); assertEquals(expected, actual); }
@Override public String render(ModelAndView modelAndView) { String viewName = templatesDirectory + "/" + modelAndView.getViewName(); JtwigTemplate template = JtwigTemplate.classpathTemplate(viewName); JtwigModel model = JtwigModel.newModel((Map) modelAndView.getModel()); return template.render(model); }
JtwigTemplateEngine extends TemplateEngine { @Override public String render(ModelAndView modelAndView) { String viewName = templatesDirectory + "/" + modelAndView.getViewName(); JtwigTemplate template = JtwigTemplate.classpathTemplate(viewName); JtwigModel model = JtwigModel.newModel((Map) modelAndView.getModel()); return template.render(model); } }
JtwigTemplateEngine extends TemplateEngine { @Override public String render(ModelAndView modelAndView) { String viewName = templatesDirectory + "/" + modelAndView.getViewName(); JtwigTemplate template = JtwigTemplate.classpathTemplate(viewName); JtwigModel model = JtwigModel.newModel((Map) modelAndView.getModel()); return template.render(model); } JtwigTemplateEngine();  JtwigTemplateEngine(String customTemplatesDirectory); }
JtwigTemplateEngine extends TemplateEngine { @Override public String render(ModelAndView modelAndView) { String viewName = templatesDirectory + "/" + modelAndView.getViewName(); JtwigTemplate template = JtwigTemplate.classpathTemplate(viewName); JtwigModel model = JtwigModel.newModel((Map) modelAndView.getModel()); return template.render(model); } JtwigTemplateEngine();  JtwigTemplateEngine(String customTemplatesDirectory); @Override String render(ModelAndView modelAndView); }
JtwigTemplateEngine extends TemplateEngine { @Override public String render(ModelAndView modelAndView) { String viewName = templatesDirectory + "/" + modelAndView.getViewName(); JtwigTemplate template = JtwigTemplate.classpathTemplate(viewName); JtwigModel model = JtwigModel.newModel((Map) modelAndView.getModel()); return template.render(model); } JtwigTemplateEngine();  JtwigTemplateEngine(String customTemplatesDirectory); @Override String render(ModelAndView modelAndView);  }