0

We're using pages with the following sort of example content:

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

And then with SiteMesh + Freemarker we decorate them in something like this:

<!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>

What I'm wondering is if there's a nice way to propagate any extra attributes on the page-level <body> element to the decorator's <body> element, so they're not simply thrown away?

Sophistifunk
  • 4,742
  • 4
  • 28
  • 37

1 Answers1

1

OK, I eventually found the answer myself after some experimentation :D The body attributes go into page.properties["body.attrName"], which you can use in my case like so:

<#if page.properties["body.class"]??>
    <body class="${page.properties["body.class"]}">
<#else>
    <body>
</#if>
Sophistifunk
  • 4,742
  • 4
  • 28
  • 37