Coming from a background in Django, I often use \"template inheritance\", where multiple templates inherit from a common base. Is there an easy way to do this in JSP? If not
Rythm Template engine has implemented an elegant approach for template inheritance.
So suppose your layout template (parent template) called main.html:
@get("title", "default main page")
@render("leftPanel")
@render("rightPanel")
@render()
And here is your target template:
@extends(main)
@set(title: "My Cool Page")
@section("leftPanel") {
}
@section("rightPanel") {
...
}
@*** note no "footer" section supplied so the default content will be used **@
@*** the rest is for the main content **@
...
Check the real demo at http://rythmengine.com/demo/testdefaultlayoutcontent
A comprehensive document could be found at http://www.playframework.org/modules/rythm. Though it's targeted to Play!Framework, most of the content also apply to pure rythm engine without Play!Framework.