Package org.apache.sling.scripting.freemarker.wrapper

Examples of org.apache.sling.scripting.freemarker.wrapper.NodeModel


    public String evalToString(String templateContent) throws Exception {
        StringReader reader = new StringReader(templateContent);
        Template template = new Template("test", reader, configuration);
       
        Map<String, TemplateModel> data = new HashMap<String, TemplateModel>();
        data.put("node", new NodeModel(node));

        StringWriter writer = new StringWriter();
        template.process(data, writer);
        return writer.toString();
    }
View Full Code Here


        String scriptName = helper.getScript().getScriptResource().getPath();

        try {
            Template tmpl = new Template(scriptName, reader, configuration);
            bindings.put("currentNode", new NodeModel((Node) bindings.get("currentNode")));
            tmpl.process(bindings, scriptContext.getWriter());
        } catch (Throwable t) {
            log.error("Failure running Freemarker script.", t);
            throw new ScriptException("Failure running FreeMarker script "
                + scriptName);
View Full Code Here

TOP

Related Classes of org.apache.sling.scripting.freemarker.wrapper.NodeModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.