Import one FTL file inside another FTL file

﹥>﹥吖頭↗ 提交于 2019-11-29 06:08:41

If you just want to include the div from one freemarker template in another freemarker template you can extract the common div out by using a macro. For example,

in macros.ftl:
<#macro filterReportDiv>
    <div id="filterReportParameters" style="display:none">
      <form ...>
    ..
      </form>
    </div>
 </#macro>

Then in both your freemarker templates, you can import macros.ftl and invoke the macro via something like:

<#import "/path/to/macros.ftl" as m>
<@m.filterReportDiv /> 

Macros are a great feature in FreeMarker and can be parameterized as well - they can really cut down on code duplication in your templates.

It sounds like you're looking for the <#include> directive - the included file will be processed by Freemarker as though it was part of the including file.

<#include "deepak.ftl"> will work if both the FTL files are in the same directory. You may use relative paths if they're not.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!