Esempio n. 1
0
 @Override
 public String render(ModelAndView modelAndView) {
   try {
     String template = locator.getString(modelAndView.getViewName(), StandardCharsets.UTF_8, null);
     return renderer.render(template, (Map<String, ?>) modelAndView.getModel());
   } catch (IOException e) {
     throw new IllegalArgumentException(e);
   }
 }
 @Override
 public String render(ModelAndView modelAndView) {
   String viewName = modelAndView.getViewName();
   try {
     Template template = handlebars.compile(viewName);
     return template.apply(modelAndView.getModel());
   } catch (IOException e) {
     throw new RuntimeIOException(e);
   }
 }
 @Override
 public String render(ModelAndView modelAndView) {
   Object model = modelAndView.getModel();
   if (model instanceof Map) {
     String template = null;
     try {
       template =
           Resources.toString(Resources.getResource(modelAndView.getViewName()), Charsets.UTF_8);
     } catch (IOException ignored) {
     }
     return jinjava.render(template, (Map<String, Object>) model);
   } else {
     throw new IllegalArgumentException("modelAndView.getModel() must return a java.util.Map");
   }
 }