我有一个模板“main.ftlh”导入另一个“template.ftlh”(包括“partialView.ftlh”)
“main.ftlh”
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<#import "template.ftlh" as my>
${my.selectOption('someKey')}
</body>
</html>
“template.ftlh”
<#assign exampleData = {"someKey" :
"<p>
This is some simple value: ${some.name} // ${some.name} equals "SOME_LOADED_VALUE"
<#include "partialView.ftlh">
//someData - from external java object e.g. contains ["firstText", "secondText"]
<#list someData as data>
<#if data.description?has_content>
<p>
This is description: ${data.description}.
</p>
</#if>
</#list>
</p>",
"otherKey" : "<p>other value</p>",
....
....
}>
<#function selectOption find="">
<#list exampleData?keys as data>
<#if data == find>
<#assign result = exampleData[data]>
</#if>
</#list>
<#return result>
</#function>
“partialView.ftlh”
This is example of content
现在如何正确地转义所有freemaker标签,以便返回如下内容:
This is some simple value: SOME_LOADED_VALUE
This is example of content
This is description: firstText
This is description: secondText