1Template::Alloy::VelociUtsye(r3)Contributed Perl DocumenTteamtpiloante::Alloy::Velocity(3)
2
3
4
6 Template::Alloy::Velocity - Velocity (VTL) role
7
9 The Template::Alloy::Velocity role provides the syntax and the
10 interface for the Velocity Templating Language (VTL). It also brings
11 many of the features from the various templating systems.
12
13 See the Template::Alloy documentation for configuration and other
14 parameters.
15
16 The following documents have more information about the velocity
17 language.
18
19 http://velocity.apache.org/engine/devel/vtl-reference-guide.html
20 http://www.javaworld.com/javaworld/jw-12-2001/jw-1228-velocity.html?page=4
21
23 Add language usage and samples.
24
26 "parse_tree_velocity"
27 Used bh the parse_tree method when SYNTAX is set to 'velocity'.
28
29 "merge"
30 Similar to process_simple, but with syntax set to velocity.
31
33 • The magic Java Velocity property lookups don't exist. You must use
34 the actual method name, Alloy will not try to guess it for you.
35 Java Velocity allows you to type $object.Attribute and Java
36 Velocity will look for the Attribute, getAttribute, getattribute,
37 isAttribute methods. In Perl Alloy, you can call
38 $object.can('Attribute') to introspect the object.
39
40 • Escaping of variables is consistent. The Java Velocity spec is
41 not. The velocity spec says that "\\$email" will return "\\$email"
42 if email is not defined and it will return "\foo" if email is equal
43 to "foo". The slash behavior magically changes according to the
44 spec. In Alloy the "\\$email" would be "\$email" if email is not
45 defined.
46
47 • You can set items to null (undefined) in Alloy. According to the
48 Java Velocity reference-guide you have to configure Velocity to do
49 this. To get the other behavior, you would need to do
50 "#if($questionable)#set($foo=$questionable)#end". The default
51 Velocity spec way provides no way for checking null return values.
52
53 • There currently isn't a "literal" directive. The VTL reference-
54 guide doesn't mention #literal, but the user-guide does. In Alloy
55 you can use the following:
56
57 #get('#foreach($a in [1..3]) $a #end')
58
59 We will probably add the literal support - but it will still have
60 to parse the document, so unless you are using compile_perl, you
61 will parse literal sections multiple times.
62
63 • There is no "$velocityCount" . Use "$loop.count" .
64
65 • In Alloy, excess whitespace outside of the directive matters. In
66 the VTL user-guide it mentions that all excess whitespace is
67 gobbled up. Alloy supports the TT chomp operators. These
68 operators are placed just inside the open and close parenthesis of
69 directives as in the following:
70
71 #set(~ $a = 1 ~)
72
73 • In Alloy, division using "/" is always floating point. If you want
74 integer division, use "div". In Java Velocity, "/" division is
75 integer only if both numbers are integers.
76
77 • Perl doesn't support negative ranges. However, arrays do have the
78 reverse method.
79
80 #foreach( $bar in [-2 .. 2].reverse ) $bar #end
81
82 • In Alloy arguments to macros are passed by value, not by name.
83 This is easy to achieve with alloy - simply encase your arguments
84 in single quotes and then eval the argument inside the macro. The
85 velocity people claim this feature as a jealously guarded feature.
86 My first template system "WrapEx" had the same feature. It
87 happened as an accident. It represents lazy software architecture
88 and is difficult to optimize.
89
91 Paul Seamons <paul@seamons.com>
92
94 This module may be distributed under the same terms as Perl itself.
95
96
97
98perl v5.36.0 2022-07-22 Template::Alloy::Velocity(3)