@Test public void test_render() throws Exception { String templateVariable = "Hello Freemarker!"; Map<String, Object> model = new HashMap<>(); model.put("message", templateVariable); String expected = String.format("<h1>%s</h1>", templateVariable); String actual = new FreeMarkerEngine().render(new ModelAndView(model, "hello.ftl")); assertEquals(expected, actual); }
@Override public String render(ModelAndView modelAndView) { try { StringWriter stringWriter = new StringWriter(); Template template = configuration.getTemplate(modelAndView.getViewName()); template.process(modelAndView.getModel(), stringWriter); return stringWriter.toString(); } catch (IOException | TemplateException e) { throw new IllegalArgumentException(e); } }
FreeMarkerEngine extends TemplateEngine { @Override public String render(ModelAndView modelAndView) { try { StringWriter stringWriter = new StringWriter(); Template template = configuration.getTemplate(modelAndView.getViewName()); template.process(modelAndView.getModel(), stringWriter); return stringWriter.toString(); } catch (IOException | TemplateException e) { throw new IllegalArgumentException(e); } } }
FreeMarkerEngine extends TemplateEngine { @Override public String render(ModelAndView modelAndView) { try { StringWriter stringWriter = new StringWriter(); Template template = configuration.getTemplate(modelAndView.getViewName()); template.process(modelAndView.getModel(), stringWriter); return stringWriter.toString(); } catch (IOException | TemplateException e) { throw new IllegalArgumentException(e); } } FreeMarkerEngine();  FreeMarkerEngine(Configuration configuration); }
FreeMarkerEngine extends TemplateEngine { @Override public String render(ModelAndView modelAndView) { try { StringWriter stringWriter = new StringWriter(); Template template = configuration.getTemplate(modelAndView.getViewName()); template.process(modelAndView.getModel(), stringWriter); return stringWriter.toString(); } catch (IOException | TemplateException e) { throw new IllegalArgumentException(e); } } FreeMarkerEngine();  FreeMarkerEngine(Configuration configuration); @Override String render(ModelAndView modelAndView); @Deprecated // use constructor void setConfiguration(Configuration configuration); }
FreeMarkerEngine extends TemplateEngine { @Override public String render(ModelAndView modelAndView) { try { StringWriter stringWriter = new StringWriter(); Template template = configuration.getTemplate(modelAndView.getViewName()); template.process(modelAndView.getModel(), stringWriter); return stringWriter.toString(); } catch (IOException | TemplateException e) { throw new IllegalArgumentException(e); } } FreeMarkerEngine();  FreeMarkerEngine(Configuration configuration); @Override String render(ModelAndView modelAndView); @Deprecated // use constructor void setConfiguration(Configuration configuration);  }