Expand my Community achievements bar.

SOLVED

Error while reading a included file in FTL

Avatar

Former Community Member

Hi, i am trying to include a html file in the FTL. it is giving 

 Error reading included file content/www/us/en/x/y/jcr:content/rr.html
The problematic instruction:
----------
==> include "${model.privacyPolicyPath}" [on line 50, column 23 in /apps/x/xx/xxx/xxxx/content/legalagreement/er.ftl]


     freemarker.template.TemplateException: Error reading included file content/www/us/en/as/asd/jcr:content/rr.html

please provide your inputs.

1 Accepted Solution

Avatar

Correct answer by
Level 8

I am not a Freemarker expert but my understanding is that include directive is only applicable for including another Freemarker template, not for including an resource like a HTML page. According to this (http://freemarker.org/docs/app_faq.html#faq_servlet_include) you have to use the include_page directive, however that directive is dependent on use of the FreemarkerServlet, which doesn't apply if you are using a Scripting Engine implementation of Freemarker. Are you using the Sling project's Freemarker scripting engine or something custom. 

View solution in original post

4 Replies

Avatar

Employee

Does the node at "/content/www/us/en/as/asd/jcr:content/rr.html" actually exist?

Avatar

Level 10

Seems like slash (/) is missing at the beginning.

Avatar

Correct answer by
Level 8

I am not a Freemarker expert but my understanding is that include directive is only applicable for including another Freemarker template, not for including an resource like a HTML page. According to this (http://freemarker.org/docs/app_faq.html#faq_servlet_include) you have to use the include_page directive, however that directive is dependent on use of the FreemarkerServlet, which doesn't apply if you are using a Scripting Engine implementation of Freemarker. Are you using the Sling project's Freemarker scripting engine or something custom. 

Avatar

Former Community Member

we are using  Sling project's Freemarker scripting engine.