【问题标题】:Insert HTML verbatim from Freemarker node从 Freemarker 节点逐字插入 HTML
【发布时间】:2015-08-12 21:08:45
【问题描述】:

我有以下 Freemarker 代码:

    <#macro table_container>
        <div class="table content">
            ${.node}
        </div>
    </#macro>

现在该节点包含我不想被 Freemarker 解析的 HTML(用于表格)。我只是希望它按原样插入。目前我收到此错误:

freemarker.template.TemplateModelException: Only elements with no child elements can be 
processed as text.
This element with name "table_container" has a child element named: table

如何让 Freemarker 逐字插入此 HTML?

【问题讨论】:

    标签: freemarker


    【解决方案1】:

    ${.node.@@markup},或者如果你在 #escape 内部,&lt;#noescape&gt;${.node.@@markup}&lt;/#noescape&gt;。虽然它会为每个这样的插入添加所需的xmlns 属性,但它有一点丑陋。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-15
      • 2016-02-21
      • 1970-01-01
      • 2015-07-01
      • 2022-01-13
      相关资源
      最近更新 更多