[
https://issues.apache.org/jira/browse/WW-4145?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13716347#comment-13716347
]
Jasper Rosenberg commented on WW-4145:
--------------------------------------
Ah, maybe this only worked for me because I needed to override the
controlheader.ftl and controlfooter.ftl files (which is why I reported this
issue in the first place).
It seems to me that the real problem is the last step: "right now S2 lost
control over inheritance as FM will try to include file:
/template/MyTheme/text.ftl which doesn't exist"
What if instead of passing in parameters.theme to the rendering, we pass in
parameters.themeHierarchy which is in this case ["MyTheme", "xhtml", "simple"]
We them have a macro which includes the first matching template found in a
theme. Something like:
{code}
<#macro includeThemeTemplate templateName>
<#list parameters.themeHierarchy as theme>
<#attempt>
<#include "/${parameters.templateDir}/${theme}/${templateName}" />
<#break/>
<#recover>
</#attempt>
</#list>
<#-- Cause an exception intentionally which will have the top most theme -->
<#include
"/${parameters.templateDir}/${parameters.themeHierarchy[0]}/${templateName}" />
</#macro>
{code}
So the new code would look like:
{code}
<@includeThemeTemplate "controlheader.ftl"/>
<#include "/${parameters.templateDir}/simple/checkboxlist.ftl" />
<@includeThemeTemplate "controlfooter.ftl"/>
{code}
This is just me writing Freemarker in place, so apologies if I have typos.
> file.ftl in xhtml theme directly references xhtml controlfooter.ftl
> -------------------------------------------------------------------
>
> Key: WW-4145
> URL: https://issues.apache.org/jira/browse/WW-4145
> Project: Struts 2
> Issue Type: Bug
> Components: Other
> Affects Versions: 2.3.15.1
> Reporter: Jasper Rosenberg
> Assignee: Lukasz Lenart
> Labels: freemarker, tags, xhtml
> Fix For: 2.3.16
>
>
> Should use $\{parameters.theme} instead so can be used in theme extension.
> {code}
> <#include "/${parameters.templateDir}/${parameters.theme}/controlheader.ftl"
> />
> <#include "/${parameters.templateDir}/simple/file.ftl" />
> <#include "/${parameters.templateDir}/${parameters.theme}/controlfooter.ftl"
> />
> {code}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira