Search code examples
javafreemarkerofbiz

include not parsing template file


I have three very simple files:

main.ftl

<#include "header.ftl">

<h1>Test</h1>

<#include "footer.ftl">

header.ftl

<h1>Header</h1>

footer.ftl

<h1>Footer</h1>

Technically it should output three h1's however my actual output is:

  1. I read that depending on the configuration the brackets for ftl might change from < and > to [ and ], I've tried changing but still nothing.
  2. I've used the * wildcard which checks parent directories and the current directory and still no luck.
  3. Freemarker documentation states that by default the include directive parses the content as a .ftl file so I should have no issues:

parse: If it is true, then the included file will be parsed as FTL, otherwise the whole file will be considered as simple text (i.e, no FreeMarker constructs will be searched in it). If you omit this option, then it defaults to true.

So why isn't my template being parsed?


Solution

  • Turns out Freemarker wasn't processing the .ftl file as an actual .ftl file as the server was rendering the content as a .jsp file, to fix I changed:

    <view-map name="frs" page="">
    

    to,

    <view-map name="frs" type="screen" page="component://ecommerce/widget/CommonScreens.xml#your-identifier"/>
    

    which fixed the rendering. By default if the type property is not defined then it is automatically rendered a JSP file.