You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by Anthony La Forge <e_...@hotmail.com> on 2001/11/24 01:53:34 UTC

Finding/Getting list of the variables from templates

After a bit of searching through the API (particularly context), I've seem to run up short.  Effectively I'm looking for a way to see which variables exist within a given template so I can limit what tasks I perform to generate content.  This would allow me to write one piece of code to respond to all of my templates (w/ out writing case specific code and templates).  Perhaps someone might have a better idea if such functionality exists, and if not, if a work around exists (w/ out the use of a custom or external parser).

Regards,

AGL


Re: Finding/Getting list of the variables from templates

Posted by Jason van Zyl <jv...@zenplex.com>.
On 11/23/01 7:53 PM, "Anthony La Forge" <e_...@hotmail.com> wrote:

> After a bit of searching through the API (particularly context), I've seem to
> run up short.  Effectively I'm looking for a way to see which variables exist
> within a given template

A template doesn't know what references tokens it contains.  I'm not sure
why you need to know that.

> so I can limit what tasks I perform to generate
> content.  

So based on a particular set of token references you want to select a mode
of processing? 

> This would allow me to write one piece of code to respond to all of
> my templates (w/ out writing case specific code and templates).

How so? You're going to need specific code in one form or another to deal
with different templates, but you can localize the logic using a pull tool.
Or a set of pull tools which you can use in all your templates.

> Perhaps 
> someone might have a better idea if such functionality exists, and if not, if
> a work around exists (w/ out the use of a custom or external parser).

Maybe you can provide us with a little use case? I honestly am not sure what
you're trying to do :-)
 
> Regards,
> 
> AGL
> 
> 

-- 

jvz.

Jason van Zyl

http://tambora.zenplex.org
http://jakarta.apache.org/turbine
http://jakarta.apache.org/velocity
http://jakarta.apache.org/alexandria
http://jakarta.apache.org/commons



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Finding/Getting list of the variables from templates

Posted by "Geir Magnusson Jr." <ge...@earthlink.net>.
On 11/23/01 7:53 PM, "Anthony La Forge" <e_...@hotmail.com> wrote:

> After a bit of searching through the API (particularly context), I've seem to
> run up short.  Effectively I'm looking for a way to see which variables exist
> within a given template so I can limit what tasks I perform to generate
> content.  This would allow me to write one piece of code to respond to all of
> my templates (w/ out writing case specific code and templates).  Perhaps
> someone might have a better idea if such functionality exists, and if not, if
> a work around exists (w/ out the use of a custom or external parser).
> 

This is a little confusing as you say you want to write one piece of code to
respond to all of your templates, yet want to do it in a template specific
way.

One way is to use a 'pull' model, putting everything into the context, and
letting the template pick and choose what it may.  However, this can be
problematic if that generation of data is resource or compute intensive, and
you would then just be wasting time and resources.

I tend to not think of it in terms of templates, but application
functionality - i.e. Suppose the user chooses to drill down into an item on
a list (say, a purchase order) - then the request from the user is more of
an action request ("Show me the purchase order for PO#123") versus a
template request ("Show me the template purchaseorderdetail.vm with
poid=123").  This means then I gather the data appropriate to the user's
request, and then choose a template to show it....  Just one way to think
about it...

geir

-- 
Geir Magnusson Jr.                                     geirm@optonline.net
System and Software Consulting
"They that can give up essential liberty to obtain a little temporary safety
deserve neither liberty nor safety." - Benjamin Franklin



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>