logo       
Bookmark and Share

Template inheritance: msg#00095

jakarta.velocity.user

Subject: Template inheritance

Hi,

I'm pretty new to Jakarta and all its sub-stuff.

I've had a look at the Cheetah template-engine written in Python and found some nice features there which I am missing in Velocity. Or maybe I just haven't discovered how to get the same out of Velocity.

Cheetah was inspired by Velocity so using a similar syntax.

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>
<table border="0" width="100%">
<tr>
<td width="1"><img src="file:///...Logo.png" alt="Logo"></td>
<th valign="middle" align="center"><font size="+3">$htTitle</font></th>
</tr>
</table>
$body
<hr width="100%" size="2">
Copyright XYZ 2003<br>
</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

## Navigation defaults to an empty string:
#def navigation
#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? How can I possibly add these features to Velocity?

I think this is a common problem and there should be anybody out there who has found a solution.

Graceful for any advice!

Regards
Dirk


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

News | Mail Home | sitemap | FAQ | advertise