AnsweredAssumed Answered

Including an ftl in another ftl

Question asked by rjohnson on May 20, 2014
I have a requirement to generate some correspondence out of Alfresco. What I do is to capture the relevant metadata in special document types and then execute a processTemplate to produce some HTML output using a freemarker template.


      var docTemplate = "/Data Dictionary/Presentation Templates/Print templates/Freemarker/Letter templates/";
      docTemplate +=  document.properties["fgic:icservlettertemplate"].toLowerCase();
      var template = companyhome.childByNamePath(docTemplate);
      var result = document.processTemplate(template);
      document.properties["fgic:icproposedresponse"] = result;


Many of these letters have "boiler plate text" in them so rather than repeating this in each template I wanted to create it once in its own freemarker template and include it in each other freemarker letter template.

There is little on the forums bout this aside from a 2008 post which I have tried to follow with no success.

So, here is what I have done, and perhaps someone can put me straight.

I have created an FTL that definitely works without an include.

In that FTL I add the line


<#assign FLTFile= companyhome.childByNamePath["Data Dictionary/Presentation Templates/Print templates/Freemarker/Letter templates/Includes/whatyoucandonow.ftl"] > <#include FLTFile.nodeRef >



This then generates an error, an excerpt from the logs is


        at freemarker.core.MixedContent.accept(MixedContent.java:92)
        at freemarker.core.Environment.visit(Environment.java:221)
        at freemarker.core.Environment.process(Environment.java:199)
        at freemarker.template.Template.process(Template.java:237)
        at org.alfresco.repo.template.FreeMarkerProcessor.processString(FreeMarkerProcessor.java:260)
        … 121 more
Caused by: java.io.FileNotFoundException: Template workspace://SpacesStore/4ff861be-fa1b-430b-bac9-b90873df34d1 not found.
        at freemarker.template.Configuration.getTemplate(Configuration.java:495)
        at freemarker.core.Environment.getTemplateForInclusion(Environment.java:1490)
        at freemarker.core.Include.accept(Include.java:157)
        … 127 more


As you can see it claims the included node does not exist, but if you copy the noderef into the node browser it definitely does exist (see attachment).

The template has 3 lines in it

<BR />
Hello this is included
<BR />


Put simply, what am I doing wrong?


Attachments

Outcomes