Using main layout template in closure templates

女生的网名这么多〃 提交于 2019-12-11 10:15:55

问题


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.


回答1:


What you could to would be something like this:

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

For example:

 {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}

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.



来源:https://stackoverflow.com/questions/8458346/using-main-layout-template-in-closure-templates

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!