You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by "Geir Magnusson Jr." <ge...@optonline.net> on 2000/11/12 09:10:01 UTC

#parse()

The first rendition of #parse() has been checked in.  I probably missed
the nightly tarball creation, so get it from CVS. After my checkin, a
fresh CVS tree built and tested correctly, so no whining if there's a
problem.  You probably have stale stuff somewhere in your CVS tree...

Usage :  
	#parse( arg )  
where
	arg = string literal or reference
ex
	#parse("storefront.vm")
	#parse( $main_frame )

Notes
=====
0) #parse(arg), unlike #include(arg), will parse VTL and render the
template specified. Remember that #include() simply spews the specified
template/content out to the output w/o any VTL processing.

1) #parse() currently takes only a single argument, unlike #include()
which can take several.  I will change this if there is interest. 

2) It behaves like #include() in that the templates to be parsed may
only come from the tree including and under TEMPLATE_ROOT for security
reasons, and .. is rejected (I hope).

3) There is recursion prevention, namely that a limited number of
#parse() statements may be executed down a single sytax tree. ('syntax
tree' := the internal representation of a template to the Velocity
engine...).  This means simply put, that it won't parse infinitely : if
you have a template foo.vm that contains within it #parse("foo.vm"),it
won't recurse infinitely.  And yes, it won't be fooled by loops (foo.vm
-> foo2.vm -> foo3.vm ->foo.vm) either.

4) The max #parse() depth is set by a property in your .properties file
called "parse_directive.maxdepth".  If you don't have a .properties
file, the default internally in the velocity.jar is 10.  If you decide
to remove that and rebuild, there is an internal safety within the code
of a depth of 20 that will apply if the property cannot be found in
either the local file or the properties built into the .jar.   If you
remove that internal safety, you deserve what you get.

Its late, and there is most likely something that I forgot to mention. 
Comments and questions welcome.  Send bugs and problems immediately :)

We're getting there...  

geir

-- 
Geir Magnusson Jr.                               geirm@optonline.com
Dakota tribal wisdom: "when you discover you are riding a dead horse,
the best strategy is to dismount."