logo       

RE: Template inheritance: msg#00096

jakarta.velocity.user

Subject: RE: Template inheritance


If your master template has all the elements that will be needed, you
could just have your dervived templates set some variables to populate
it using a #set then a #parse to include the whole master template.

I don't think that gets you where you want to go, but it could get you
half way... You could abstract some of it out. I have not tried to
throw a lot of html into a set, but the theory works I think...








-----Original Message-----
From: dh.discuss@xxxxxx [mailto:dh.discuss@xxxxxx]
Sent: Sunday, May 18, 2003 7:14 AM
To: velocity-user@xxxxxxxxxxxxxxxxxx
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




---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@xxxxxxxxxxxxxxxxxx
For additional commands, e-mail: velocity-user-help@xxxxxxxxxxxxxxxxxx


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

News | FAQ | advertise