velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Geir Magnusson Jr." <ge...@optonline.net>
Subject Re: Dynamic Nested Templates -Don't Agree that this is not what Velo is for
Date Sun, 11 Nov 2001 02:58:57 GMT
On 11/10/01 9:05 PM, "Robert Edgar" <robert.edgar@eeplace.com> wrote:

> Guys,
> Maybe I didn't explain myself clearly, my fault!
> 
> No problem, anyway here is my "take" on things.
> 
> I understand that Velocity is a templating engine, we are currently using
> XSL as our templating engine, I have a standard "template" which is a large
> XSL stylesheet, actually I have several "standard" templates covering
> different sorts of pages that I have on my web site. Within a standard
> template I then load sub-templates to format different sections, so on my
> site home page I have the main page template and sub templates for a section
> on latest news .

So far so good.  This is the kind of thing you can do with #parse(), for
example.

> 
> Now to me this is EXACTLY what velocity is about.
> 
> The only issue I had here was that Velocity "seemed" to require a template
> to be fixed rather than dynamic in that although it can have nested
> templates,

What do you mean 'fixed'?

A common technique is to setup a 'frame' or 'layout' that positions the
parts of the page, such as the top, nav section, footer, and body, and then
you use references to setup all the parts.... Something like


<table>
 <tr>
   <td colspan=2>
       #parse( $header )
   </td>
 </tr>
 <tr>
    <td>
       #parse( $leftnav )
    </td>
    <td>
       #parse( $body )
    </td>
 </tr>
 <tr>
    <td colspan=2>
     #parse($footer)
    </td>
 </tr>
</table>

And then the servlet choose the $header, $leftnav, $body and $footer based
on user and current context of the app.
 
Just one approach among many...

> using the #parse directive, these are preset in the template
> whereas I wanted something dynamic in that a template will display a VAR at
> a point in the template but I want the VAR to be the output of #parse some
> previous template.

#parse() can take references, so the actual thing can be chose independently
of the framing/layout tempalte
> AND
> 
> After looking a bit father myself it "seems" to me my "standard" templates
> can be loaded as Velocity Macro's in the form of the global library.

Hm

> My
> understanding is that a Macro is called and is passed parameters which can
> be anything including the rendered output of another template. If that is
> the case that almost exactly matches an XSL call-template directive.

Sure.  You can do something like

#set($templateoutput = "#parse($foo)")

#myvelocimacro( $templateoutput )


(note the " in the #set() )
 
> So ....  correct me if I am wrong .... but to me this is exactly what Velo
> is about and it can do what I want...

Then switch as fast as you can :)

I like XSL but I think it's really challenging for the view layer :)

geir

-- 
Geir Magnusson Jr.     geirm@optonline.net
System and Software Consulting
"Whoever would overthrow the liberty of a nation must begin by subduing the
freeness of speech." - Benjamin Franklin



--
To unsubscribe, e-mail:   <mailto:velocity-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:velocity-user-help@jakarta.apache.org>


Mime
View raw message