@Test public void test_render() throws Exception { String templateVariable = "Hello Jetbrick!"; Map<String, Object> model = new HashMap<>(); model.put("message", templateVariable); String expected = String.format("<h1>%s</h1>", templateVariable); String actual = new JetbrickTemplateEngine().render(new ModelAndView(model, "template/hello.jetx")); assertEquals(expected, actual); }
@Override public String render(ModelAndView modelAndView) { JetTemplate template = jetEngine.getTemplate(modelAndView.getViewName()); Object model = modelAndView.getModel(); if (model instanceof Map) { Map<String, Object> modelMap = (Map<String, Object>) model; JetContext context = new JetContext(modelMap.size()); context.putAll(modelMap); StringWriter writer = new StringWriter(); template.render(context, writer); return writer.toString(); } else { throw new IllegalArgumentException("modelAndView.getModel() must return a java.util.Map"); } }
JetbrickTemplateEngine extends TemplateEngine { @Override public String render(ModelAndView modelAndView) { JetTemplate template = jetEngine.getTemplate(modelAndView.getViewName()); Object model = modelAndView.getModel(); if (model instanceof Map) { Map<String, Object> modelMap = (Map<String, Object>) model; JetContext context = new JetContext(modelMap.size()); context.putAll(modelMap); StringWriter writer = new StringWriter(); template.render(context, writer); return writer.toString(); } else { throw new IllegalArgumentException("modelAndView.getModel() must return a java.util.Map"); } } }
JetbrickTemplateEngine extends TemplateEngine { @Override public String render(ModelAndView modelAndView) { JetTemplate template = jetEngine.getTemplate(modelAndView.getViewName()); Object model = modelAndView.getModel(); if (model instanceof Map) { Map<String, Object> modelMap = (Map<String, Object>) model; JetContext context = new JetContext(modelMap.size()); context.putAll(modelMap); StringWriter writer = new StringWriter(); template.render(context, writer); return writer.toString(); } else { throw new IllegalArgumentException("modelAndView.getModel() must return a java.util.Map"); } } JetbrickTemplateEngine();  JetbrickTemplateEngine(JetEngine jetEngine); }
JetbrickTemplateEngine extends TemplateEngine { @Override public String render(ModelAndView modelAndView) { JetTemplate template = jetEngine.getTemplate(modelAndView.getViewName()); Object model = modelAndView.getModel(); if (model instanceof Map) { Map<String, Object> modelMap = (Map<String, Object>) model; JetContext context = new JetContext(modelMap.size()); context.putAll(modelMap); StringWriter writer = new StringWriter(); template.render(context, writer); return writer.toString(); } else { throw new IllegalArgumentException("modelAndView.getModel() must return a java.util.Map"); } } JetbrickTemplateEngine();  JetbrickTemplateEngine(JetEngine jetEngine); @Override String render(ModelAndView modelAndView); }
JetbrickTemplateEngine extends TemplateEngine { @Override public String render(ModelAndView modelAndView) { JetTemplate template = jetEngine.getTemplate(modelAndView.getViewName()); Object model = modelAndView.getModel(); if (model instanceof Map) { Map<String, Object> modelMap = (Map<String, Object>) model; JetContext context = new JetContext(modelMap.size()); context.putAll(modelMap); StringWriter writer = new StringWriter(); template.render(context, writer); return writer.toString(); } else { throw new IllegalArgumentException("modelAndView.getModel() must return a java.util.Map"); } } JetbrickTemplateEngine();  JetbrickTemplateEngine(JetEngine jetEngine); @Override String render(ModelAndView modelAndView);  }