I was unable to get Velocity to work, however I switched to FreeMarker and
was able to get things to work with the following configuration. This should
provide an example to anybody else who may encounter issues similar to the
ones I had. 

pom.xml

        <dependency>
            <groupId>org.freemarker</groupId>
            <artifactId>freemarker</artifactId>
            <version>2.3.19</version>
        </dependency>
                
        <dependency>
            <groupId>org.chenillekit</groupId>
            <artifactId>chenillekit-template</artifactId>
            <version>1.3.3</version>
        </dependency>

AppModule

    /*
     * FreeMarker Services
     */
    public static void
contributeFreeMarkerService(MappedConfiguration<String,
freemarker.template.Configuration> configuration) {
        freemarker.template.Configuration fmConfiguration = new
freemarker.template.Configuration();
        fmConfiguration.setWhitespaceStripping(false);
       
fmConfiguration.setClassForTemplateLoading(fmConfiguration.getClass(), "/");
        configuration.add("freemarker.configuration", fmConfiguration);
    }

FreeMarkerServiceImpl

    private final PageRenderLinkSource pageRenderLinkSource;
    
    private final TemplateService templateService;

    public FreeMarkerServiceImpl(@FreeMarker TemplateService
templateService, PageRenderLinkSource pageRenderLinkSource) {
        this.templateService = templateService;
        this.pageRenderLinkSource = pageRenderLinkSource;
    }

    public String emailBodyTemplate(String template, YourObject obj) {
        String pr_url =
this.pageRenderLinkSource.createPageRenderLinkWithContext(YourObject.class,
obj.getId()).toAbsoluteURI();
        
        InputStream input = new ByteArrayInputStream(template.getBytes());
        OutputStream output = new ByteArrayOutputStream();

        Map parameterMap = new HashMap();
        parameterMap.put("obj_number", obj.getobjNumber());
        parameterMap.put("obj_url", obj_url);
        templateService.mergeDataWithStream(input, output, parameterMap);

        return output.toString();
    }





--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Configuring-Chenillekit-template-with-tapestry-tp5717522p5717542.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to