You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Jason van Zyl <jv...@zenplex.com> on 2002/05/24 01:39:59 UTC

Re: Parsing velocity code within a velocity screen.

On Sun, 2002-05-26 at 05:35, rpiper wrote:
> I would like to be able to parse velocity code from a string, rather 
> than a vm template.
> So rather than:
> 
> #parse("filename.vm")
> 
> do something like:
> 
> #evaluate(" This is a $test, of velocity ") , where say $test is a 
> string object on the context.
> 
> I would be grateful for any suggestions.
> 
> Basically I want to store the navigation templates in a database, and 
> therefore need to be able to evaluate
> these from within other navigation or screen templates as a string 
> (rather than template file), retrieved from a database..
> 
> thanks

#evaluate ( $dbTool.getVTL("siteNavigation") )

You could make a little tool that retrieves your VTL from the database
and you can use that directly as a parameter to the evaluate directive.

I can't remember if #evaluate is even a directive so you might have to
make a tool to do the evaluations for you, but in either case I don't
think you will have much problem getting this working.

Have you look at the DataSourceResourceLoader in velocity yet? You could
also use this to get VTL from a DataSource.

http://cvs.apache.org/viewcvs/jakarta-velocity/src/java/org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.java?rev=1.8&content-type=text/vnd.viewcvs-markup

There are also some docs on the DataSourceResourceLoader in the vel
docs:

http://jakarta.apache.org/velocity/developer-guide.html#Resource%20Loaders


> Richard
> 
> -- 
> Richard Piper
> 
> http://icu-web.org
> mail:rpiper@med.usyd.edu.au
> 
> 
> 
> 
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
-- 
jvz.

Jason van Zyl
jvanzyl@apache.org

http://tambora.zenplex.org


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


Re: Parsing velocity code within a velocity screen.

Posted by rpiper <rp...@med.usyd.edu.au>.
Jason van Zyl wrote:

>On Sun, 2002-05-26 at 05:35, rpiper wrote:
>  
>
>>I would like to be able to parse velocity code from a string, rather 
>>than a vm template.
>>So rather than:
>>
>>#parse("filename.vm")
>>
>>do something like:
>>
>>#evaluate(" This is a $test, of velocity ") , where say $test is a 
>>string object on the context.
>>
>>I would be grateful for any suggestions.
>>
>>Basically I want to store the navigation templates in a database, and 
>>therefore need to be able to evaluate
>>these from within other navigation or screen templates as a string 
>>(rather than template file), retrieved from a database..
>>
>>thanks
>>    
>>
>
>#evaluate ( $dbTool.getVTL("siteNavigation") )
>
>You could make a little tool that retrieves your VTL from the database
>and you can use that directly as a parameter to the evaluate directive.
>
>I can't remember if #evaluate is even a directive so you might have to
>make a tool to do the evaluations for you, but in either case I don't
>think you will have much problem getting this working.
>
>  
>
Thanks, #evaluate is not a directive, I just made it up ... based on the 
Velocity.evaluate method.  But I can see how I can do this now.

>Have you look at the DataSourceResourceLoader in velocity yet? You could
>also use this to get VTL from a DataSource.
>
>http://cvs.apache.org/viewcvs/jakarta-velocity/src/java/org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.java?rev=1.8&content-type=text/vnd.viewcvs-markup
>
>There are also some docs on the DataSourceResourceLoader in the vel
>docs:
>
>http://jakarta.apache.org/velocity/developer-guide.html#Resource%20Loaders
>
I did see this, and will have a closer look.

thanks

Richard

- 
Richard Piper

http://icu-web.org
mail:rpiper@med.usyd.edu.au







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