logo       

Re: Template inheritance: msg#00097

jakarta.velocity.user

Subject: Re: Template inheritance

Dirk said:
...
> I want to build up a hierarchy of templates as outlined below.:
>
> MasterPage.tmpl: A master template containing a header and a footer
at
> the top of the hierarchy (note the placeholders $htTitle and $body)
> ---------------------------------------------------------
> <!DOCTYPE html ... >
> <html><head>...</head>
> <body>
> $body
> </body>
> </html>
> ---------------------------------------------------------
> A.tmpl: Example for a template that extends the master template:
(Note
> the placeholders $navigation and $content)
> ---------------------------------------------------------
> #extends MasterPage
>
> #def body
> <table border="0" width="100%">
> <tr> <td width="1">$navigation</td><td
valign="top">$content</td> </tr>
> </table>
> #end def
> ---------------------------------------------------------
> There may be more templates using #extends and #def/#end def and
> containing placeholders to build up a hierarchy of templates without
> writing any redundant stuff. All templates can be written using an
> HTML-WYSIWYG-editor.
>
> How can I achieve this within the Jakarta environment or using
Velocity?

Velocity doesn't give you the ability to extend templates in such a
manner, nor is such a feature planned AFAIK. since you appear to be
creating a webapp, i recommend checking out the jakarta-velocity-tools
project. it provides a VelocityLayoutServlet that can offer
functionality somewhat similar to this. with it you would define one
(a default) or more "layout" templates analagous to your master
template, and "body" or "screen content" templates would be able to
set variables for the layout. the screen template could also override
(even dynamically, if you want) the layout to be used if the default
one is not desired.

anyway, you can check the project out and build the docs yourself, or
peruse them online first at
http://www.happysearch.com/velocity/tools/docs/
we haven't gotten them up on the main jakarta site yet.

Nathan Bubna
nathan@xxxxxxxx


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise