我正在使用闭包模板,我无法弄清楚如何让一个主要模板具有常见的东西,如徽标,当我渲染其他模板时,它们将在主要模板中呈现。我想为每个模板都有一个servlet。
答案 0 :(得分:3)
你可以做到这样的事情:
从其他模板中调用主模板。在其他模板中,您可以定义主模板的参数。
例如:
{namespace com.example}
/**
* Says hello to a person (or to the world if no person is given).
* @param title the page title
* @param body the page body
*/
{template .base}
<html>
<head>
<title>{$title}</title>
</head>
<body>
{$body}
</body>
</html>
{/template}
/**
* Search Result
*/
{template .servlet1}
{call base}
{param title}
Example Title
{/param}
{param body}
Here comes my body!
{/param}
{/call}
{/template}
当然,如果你想拥有一个灵活而完整的html页面,你最终会得到很多参数。但这应该引导你。