protected TemplateStore store(final ResourceLoader templateLoader) { return name -> { byte[] bytes = templateLoader.load(name); U.must(bytes != null, "The Rapidoid template '%s' doesn't exist!", name); return new String(bytes); }; }
protected MustacheResolver mustacheResolver(final ResourceLoader templateLoader) { return name -> { try { byte[] bytes = templateLoader.load(name); U.must(bytes != null, "The Mustache.java template '%s' doesn't exist!", name); return new StringReader(new String(bytes)); } catch (Exception e) { throw U.rte(e); } }; }
protected Mustache.TemplateLoader loader(final ResourceLoader templateLoader) { return name -> { String filename = filename(name); byte[] bytes = templateLoader.load(filename); U.must(bytes != null, "The JMustache template '%s' doesn't exist!", filename); return new StringReader(new String(bytes)); }; }
@Override public View getView(String viewName, ResourceLoader resourceLoader) throws Exception { String filename = filename(viewName); if (resourceLoader.load(filename) == null) return null; DefaultMustacheFactory mf = getViewFactory(resourceLoader); Mustache mustache = mf.compile(filename); return view(mustache); }
@Override public View getView(String viewName, final ResourceLoader resourceLoader) throws Exception { String filename = filename(viewName); byte[] bytes = resourceLoader.load(filename); if (bytes == null) return null; Mustache.TemplateLoader loader = loader(resourceLoader); String template = new String(bytes); Mustache.Compiler compiler = getViewFactory(resourceLoader); Template mustache = compiler.withLoader(loader).compile(template); return view(mustache); }
@Override public View getView(String viewName, final ResourceLoader resourceLoader) throws Exception { String filename = filename(viewName); if (resourceLoader.load(filename) == null) return null; TemplateFactory templateFactory = getViewFactory(resourceLoader); Template template = templateFactory.load(filename, Object.class); return template != null ? view(template) : null; }
@Override public String loadTemplate(String name) throws Exception { byte[] bytes = templateLoader.load(name); U.must(bytes != null, "The Rapidoid template '%s' doesn't exist!", name); return new String(bytes); } };
@Override public View getView(String viewName, final ResourceLoader resourceLoader) throws Exception { String filename = filename(viewName); if (resourceLoader.load(filename) == null) return null; TemplateFactory templateFactory = getViewFactory(resourceLoader); Template template = templateFactory.load(filename, Object.class); return template != null ? view(template) : null; }