Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages


home | help
Template::Alloy::VelocUser3Contributed Perl DocumeTemplate::Alloy::Velocity(3)

       Template::Alloy::Velocity - Velocity (VTL) role

       The Template::Alloy::Velocity role provides the syntax and the
       interface for the Velocity Templating Language (VTL).  It also brings
       many of the features from the various templating	systems.

       See the Template::Alloy documentation for configuration and other

       The following documents have more information about the velocity

       Add language usage and samples.

	   Used	bh the parse_tree method when SYNTAX is	set to 'velocity'.

	   Similar to process_simple, but with syntax set to velocity.

       o   The magic Java Velocity property lookups don't exist.  You must use
	   the actual method name, Alloy will not try to guess it for you.
	   Java	Velocity allows	you to type $object.Attribute and Java
	   Velocity will look for the Attribute, getAttribute, getattribute,
	   isAttribute methods.	 In Perl Alloy,	you can	call
	   $object.can('Attribute') to introspect the object.

       o   Escaping of variables is consistent.	 The Java Velocity spec	is
	   not.	 The velocity spec says	that "\\$email"	will return "\\$email"
	   if email is not defined and it will return "\foo" if	email is equal
	   to "foo".  The slash	behavior magically changes according to	the
	   spec.  In Alloy the "\\$email" would	be "\$email" if	email is not

       o   You can set items to	null (undefined) in Alloy.  According to the
	   Java	Velocity reference-guide you have to configure Velocity	to do
	   this.  To get the other behavior, you would need to do
	   "#if($questionable)#set($foo=$questionable)#end".  The default
	   Velocity spec way provides no way for checking null return values.

       o   There currently isn't a "literal" directive.	 The VTL reference-
	   guide doesn't mention #literal, but the user-guide does.  In	Alloy
	   you can use the following:

	       #get('#foreach($a in [1..3]) $a #end')

	   We will probably add	the literal support - but it will still	have
	   to parse the	document, so unless you	are using compile_perl,	you
	   will	parse literal sections multiple	times.

       o   There is no "$velocityCount"	.  Use "$loop.count" .

       o   In Alloy, excess whitespace outside of the directive	matters.  In
	   the VTL user-guide it mentions that all excess whitespace is
	   gobbled up.	Alloy supports the TT chomp operators.	These
	   operators are placed	just inside the	open and close parenthesis of
	   directives as in the	following:

		#set(~ $a = 1 ~)

       o   In Alloy, division using "/"	is always floating point.  If you want
	   integer division, use "div".	 In Java Velocity, "/" division	is
	   integer only	if both	numbers	are integers.

       o   Perl	doesn't	support	negative ranges.  However, arrays do have the
	   reverse method.

		#foreach( $bar in [-2 .. 2].reverse ) $bar #end

       o   In Alloy arguments to macros	are passed by value, not by name.
	   This	is easy	to achieve with	alloy -	simply encase your arguments
	   in single quotes and	then eval the argument inside the macro.  The
	   velocity people claim this feature as a jealously guarded feature.
	   My first template system "WrapEx" had the same feature.  It
	   happened as an accident.  It	represents lazy	software architecture
	   and is difficult to optimize.

       Paul Seamons <>

       This module may be distributed under the	same terms as Perl itself.

perl v5.32.1			  2013-08-22	  Template::Alloy::Velocity(3)


Want to link to this manual page? Use this URL:

home | help