Domanda

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.

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top