@Test public void testRender() throws Exception { final String templateVariable = "Hello Soy!"; final Map<String, Object> model = new HashMap<>(); model.put("message", templateVariable); final String expected = String.format("<h1>%s</h1>", templateVariable); final String actual = new ClosureTemplateEngine("hello.soy") .render(new ModelAndView(model, "spark.template.closure.hello")); assertEquals(expected, actual); }
@Override @SuppressWarnings("unchecked") public String render(final ModelAndView modelAndView) { final String templateName = modelAndView.getViewName(); if (modelAndView.getModel() instanceof Map) { final Map<String, ?> soyMapData = (Map<String, ?>) modelAndView.getModel(); return soyTofu.newRenderer(templateName).setData(soyMapData).render(); } throw new IllegalArgumentException("Expecting the model to be an instance of Map<String, ?>"); }
ClosureTemplateEngine extends TemplateEngine { @Override @SuppressWarnings("unchecked") public String render(final ModelAndView modelAndView) { final String templateName = modelAndView.getViewName(); if (modelAndView.getModel() instanceof Map) { final Map<String, ?> soyMapData = (Map<String, ?>) modelAndView.getModel(); return soyTofu.newRenderer(templateName).setData(soyMapData).render(); } throw new IllegalArgumentException("Expecting the model to be an instance of Map<String, ?>"); } }
ClosureTemplateEngine extends TemplateEngine { @Override @SuppressWarnings("unchecked") public String render(final ModelAndView modelAndView) { final String templateName = modelAndView.getViewName(); if (modelAndView.getModel() instanceof Map) { final Map<String, ?> soyMapData = (Map<String, ?>) modelAndView.getModel(); return soyTofu.newRenderer(templateName).setData(soyMapData).render(); } throw new IllegalArgumentException("Expecting the model to be an instance of Map<String, ?>"); } ClosureTemplateEngine(final String... soyFilePaths);  ClosureTemplateEngine(final SoyTofu soyTofu); }
ClosureTemplateEngine extends TemplateEngine { @Override @SuppressWarnings("unchecked") public String render(final ModelAndView modelAndView) { final String templateName = modelAndView.getViewName(); if (modelAndView.getModel() instanceof Map) { final Map<String, ?> soyMapData = (Map<String, ?>) modelAndView.getModel(); return soyTofu.newRenderer(templateName).setData(soyMapData).render(); } throw new IllegalArgumentException("Expecting the model to be an instance of Map<String, ?>"); } ClosureTemplateEngine(final String... soyFilePaths);  ClosureTemplateEngine(final SoyTofu soyTofu); @Override @SuppressWarnings("unchecked") String render(final ModelAndView modelAndView); }
ClosureTemplateEngine extends TemplateEngine { @Override @SuppressWarnings("unchecked") public String render(final ModelAndView modelAndView) { final String templateName = modelAndView.getViewName(); if (modelAndView.getModel() instanceof Map) { final Map<String, ?> soyMapData = (Map<String, ?>) modelAndView.getModel(); return soyTofu.newRenderer(templateName).setData(soyMapData).render(); } throw new IllegalArgumentException("Expecting the model to be an instance of Map<String, ?>"); } ClosureTemplateEngine(final String... soyFilePaths);  ClosureTemplateEngine(final SoyTofu soyTofu); @Override @SuppressWarnings("unchecked") String render(final ModelAndView modelAndView);  }