public String output (JtwigContext context) throws ParseException, CompileException, RenderException { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); output(outputStream, context); return outputStream.toString(); }
private Renderable getCompiledJtwigTemplate() throws ParseException, CompileException { return new JtwigTemplate(getResource(), getConfiguration()).compile(); }
@Override public String renderAsString(Path templatePath, Map<String, Object> data) throws TemplateRenderingException { JtwigTemplate template = new JtwigTemplate(new JailedPathJtwigResource(fileManager.resolvePermanentFilePath(Paths.get(".")), templatePath), new JtwigConfiguration()); JtwigModelMap model = new JtwigModelMap(); model.add(data); try { return template.output(model); } catch (CompileException | RenderException | ParseException e) { throw new TemplateRenderingException(e); } } }
@Override public void render(Path templatePath, Map<String, Object> data, OutputStream outputStream) throws TemplateRenderingException { JtwigTemplate template = new JtwigTemplate(new JailedPathJtwigResource(fileManager.resolvePermanentFilePath(Paths.get(".")), templatePath), new JtwigConfiguration()); JtwigModelMap model = new JtwigModelMap(); model.add(data); try { template.output(outputStream, model); } catch (CompileException | RenderException | ParseException e) { throw new TemplateRenderingException(e); } }
public String output (JtwigContext context) throws ParseException, CompileException, RenderException { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); output(outputStream, context); return outputStream.toString(); }