0

我们正在使用具有以下示例内容的页面:

<html>
    <head>
        <title>Page Title</title>
        <!-- (page-specific JS and styles) -->
    </head>
    <body>
        <h1>Page Title</h1>
        <!-- (rest of page content) -->
    </body>
</html>

然后使用 SiteMesh + Freemarker 我们将它们装饰成这样:

<!doctype html>
<html>
    <head>
        <title><#if title?? && title?has_content>${title}</#if></title>
        <!-- (global styles and scripts)-->
        ${head}
    </head>
    <body>
        <!-- (Header elements) -->
        ${body}
        <!-- (Footer elements) -->
    </body>
</html>

我想知道是否有一种很好的方法可以将页面级<body>元素上的任何额外属性传播到装饰器的<body>元素,所以它们不会被简单地丢弃?

4

1 回答 1

1

好的,经过一些实验,我最终自己找到了答案:D 身体属性进入page.properties["body.attrName"],您可以在我的情况下使用,如下所示:

<#if page.properties["body.class"]??>
    <body class="${page.properties["body.class"]}">
<#else>
    <body>
</#if>
于 2012-10-25T06:13:08.177 回答