Search in sources :

Example 41 with Template

use of groovy.text.Template in project indy by Commonjava.

the class TemplatingEngine method render.

public String render(final String acceptHeader, final String templateKey, final Map<String, Object> params) throws IndyGroovyException {
    final Template template = getTemplate(acceptHeader, templateKey);
    final Writable output = template.make(params);
    final StringWriter writer = new StringWriter();
    try {
        output.writeTo(writer);
    } catch (final IOException e) {
        throw new IndyGroovyException("Failed to render template: %s for addMetadata: %s. Reason: %s", e, templateKey, acceptHeader, e.getMessage());
    }
    return writer.toString();
}
Also used : StringWriter(java.io.StringWriter) Writable(groovy.lang.Writable) IOException(java.io.IOException) Template(groovy.text.Template)

Aggregations

Template (groovy.text.Template)41 IOException (java.io.IOException)19 HashMap (java.util.HashMap)7 ServletException (javax.servlet.ServletException)7 Writable (groovy.lang.Writable)6 SimpleTemplateEngine (groovy.text.SimpleTemplateEngine)6 Writer (java.io.Writer)6 File (java.io.File)5 StringWriter (java.io.StringWriter)3 URL (java.net.URL)3 GroovyObject (groovy.lang.GroovyObject)2 FileInputStream (java.io.FileInputStream)2 InputStreamReader (java.io.InputStreamReader)2 OutputStreamWriter (java.io.OutputStreamWriter)2 Reader (java.io.Reader)2 StringReader (java.io.StringReader)2 GrailsTagException (org.grails.taglib.GrailsTagException)2 Test (org.junit.Test)2 WebConfig (com.haulmont.cuba.web.WebConfig)1 TestExplanation1 (eu.esdihumboldt.hale.common.align.model.impl.mdexpl.test.TestExplanation1)1