在闭包模板中使用主布局模板 [英] Using main layout template in closure templates

查看:89
本文介绍了在闭包模板中使用主布局模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是闭包模板,我不知道如何使用一个带有诸如徽标之类的常用东西的主模板,而当我渲染其他模板时,它们将被渲染在主模板中.我希望每个模板都有一个servlet.

I'm using closure templates and I can't figure out how to have one main template with common stuff such as logo and when I render other templates they will be rendered inside the main one. I want to have a servlet for each template.

推荐答案

您可能会这样:

从其他模板内部调用主模板.在其他模板中,您可以定义主模板的参数.

Call the main template from inside the other templates. Inside the other templates you can define the parameters for your main template.

例如:

 {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页面,那么您当然会有很多参数.但这应该可以带您前进.

Of course you end up with a lot of parameters if you want to have a flexible and full html page. But this should lead you the way.

这篇关于在闭包模板中使用主布局模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆