Search in sources :

Example 1 with TemplateEngine

use of org.apache.marmotta.ldpath.template.engine.TemplateEngine in project stanbol by apache.

the class LdRenderer method render.

/**
	 * Renders a GraphNode with a template located in the templates
	 * folder of any active bundle
	 * 
	 * @param node the GraphNode to be rendered
	 * @param templatePath the freemarker path to the template
	 * @param out where the result is written to
	 */
public void render(GraphNode node, final String templatePath, Writer out) {
    //A GraphNode backend could be graph unspecific, so the same engine could be
    //reused, possibly being signifantly more performant (caching, etc.)
    RDFBackend<RDFTerm> backend = new ClerezzaBackend(node.getGraph());
    RDFTerm context = node.getNode();
    TemplateEngine<RDFTerm> engine = new TemplateEngine<RDFTerm>(backend);
    engine.setTemplateLoader(templateLoader);
    try {
        engine.processFileTemplate(context, templatePath, null, out);
        out.flush();
    } catch (IOException e) {
        throw new RuntimeException(e);
    } catch (TemplateException e) {
        throw new RuntimeException(e);
    }
}
Also used : TemplateEngine(org.apache.marmotta.ldpath.template.engine.TemplateEngine) TemplateException(freemarker.template.TemplateException) ClerezzaBackend(org.apache.stanbol.commons.ldpath.clerezza.ClerezzaBackend) RDFTerm(org.apache.clerezza.commons.rdf.RDFTerm) IOException(java.io.IOException)

Aggregations

TemplateException (freemarker.template.TemplateException)1 IOException (java.io.IOException)1 RDFTerm (org.apache.clerezza.commons.rdf.RDFTerm)1 TemplateEngine (org.apache.marmotta.ldpath.template.engine.TemplateEngine)1 ClerezzaBackend (org.apache.stanbol.commons.ldpath.clerezza.ClerezzaBackend)1