groovy template inheritance?

Asked by Chris Lu

According to the page http://www.playframework.org/manual/contents/templates, there is template inheritance.

However, from the description, I can only know how to inherit from the "main.html", and overwrite the part #{doLayout /}

Is it possible to create a template that I can overwrite several parts? Like one is for the main content, and the other for the sidebar content, and another part for a different menu?

btw: Where to find more details about groovy templates?

Question information

Language:
English Edit question
Status:
Solved
For:
play framework Edit question
Assignee:
No assignee Edit question
Solved by:
Guillaume Bort
Solved:
Last query:
Last reply:
Revision history for this message
Best Guillaume Bort (guillaume-bort) said :
#1

Yes, you can use #{get /} and #{set /} to define more parts.
Something like :

/app/views/main.html :

<html>
   <body>
      <div id="main">
           #{get 'main' /}
      </div>
      <div id="sidebar">
           #{get 'sidebar' /}
      </div>
   </body>
</html>

and in /app/views/Application/index.html :

#{extends 'main.html' /}

#{set 'main'}
    <h1>This is the main part</h1>
#{/set}

#{set 'sidebar'}
    <ul id="menu">
       <li>...</li>
    </ul>
#{/set}

Revision history for this message
Chris Lu (chris-lu) said :
#2

Thanks Guillaume Bort, that solved my question.