GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Template::Alloy::Velocity(3) User Contributed Perl Documentation Template::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 parameters.

The following documents have more information about the velocity language.

    http://velocity.apache.org/engine/devel/vtl-reference-guide.html
    http://www.javaworld.com/javaworld/jw-12-2001/jw-1228-velocity.html?page=4

Add language usage and samples.

"parse_tree_velocity"
Used bh the parse_tree method when SYNTAX is set to 'velocity'.
"merge"
Similar to process_simple, but with syntax set to velocity.

  • 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.
  • 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 defined.
  • 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.
  • 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.

  • There is no "$velocityCount" . Use "$loop.count" .
  • 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 ~)
        
  • 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.
  • Perl doesn't support negative ranges. However, arrays do have the reverse method.

         #foreach( $bar in [-2 .. 2].reverse ) $bar #end
        
  • 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 <paul@seamons.com>

This module may be distributed under the same terms as Perl itself.
2020-07-11 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.