Is it possible to decorate more than once in Sitem

2020-02-28 05:56发布

I'm trying to do something like this: the layout

For all the requests to /admin/* I need the page to be decorated using the B decorator but also that B decorator has to be included in the content of A decorator which is main application layout.

How can I do that with Sitemesh?

Is it even possible? Or do I have to repeat the same layout from A in the B decorator?

Thanks in advance

2条回答
我命由我不由天
2楼-- · 2020-02-28 06:20

Here's the example using freemarker:

<#assign decorator = JspTaglibs["http://www.opensymphony.com/sitemesh/decorator"]/>
<#assign page = JspTaglibs["http://www.opensymphony.com/sitemesh/page"]/>
<@page.applyDecorator name="a">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>Decorator B</title>
    <@decorator.head/>
</head>
<body id="page-home">
    This is a test.
</body>
</html>
</@page.applyDecorator>
查看更多
家丑人穷心不美
3楼-- · 2020-02-28 06:23

To answer my own question. Yes it is possible:

Using my own example, this is decorator b being decorated by decorator a.

<page:applyDecorator name="a">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>Decorator B</title>
    <decorator:head/>
</head>
<body id="page-home">
    This is a test.
</body>
</html>
</page:applyDecorator>
查看更多
登录 后发表回答