Templa...elocity(3pm)
π Templa...elocity(3pm) β the User Contributed Perl Documentation glow-up π
okay bestie, welcome to the manual page for Templa...elocity(3pm), aka the Template::Alloy::Velocity era. it's giving "Perl does Velocity but make it make sense." let's get into it β¨
πΈ NAME πΈ
Template::Alloy::Velocity β the Velocity (VTL) role. yes, that's it. that's the whole name. iconic. π
π¦ DESCRIPTION π¦
so the Template::Alloy::Velocity role hands you both the syntax and the interface for the Velocity Templating Language (VTL). and not just that β it also pulls in a whole bunch of features from the various templating systems out there. it's lowkey a whole buffet. π
if you need config deets and other parameters, go check the Template::Alloy documentation, that's where all of that lives. β¨
and if you want to actually learn the velocity language, these docs right here have more info:
http://velocity.apache.org/engine/devel/vtl-reference-guide.html
http://www.javaworld.com/javaworld/jw-12-2001/jw-1228-velocity.html?page=4
π TODO π
Add language usage and samples.
(yes that's the entire TODO section. she's short. she's honest. we respect her. π)
π ROLE METHODS π
parse_tree_velocityβ this one gets used by theparse_treemethod whenSYNTAXis set to'velocity'. that's her whole job and she does it flawlessly. πmergeβ basicallyprocess_simple, but with the syntax set to velocity. same energy, different syntax vibe check. β¨
π UNSUPPORTED VELOCITY SPEC π
okay so this is the part where we keep it real: here's everything that Alloy does not do the Java Velocity way. no cap, read this part carefully bestie, it will save you so much confusion. π«Ά
- the magic Java Velocity property lookups don't exist. nope, not a thing. you have to use the actual method name β Alloy is not gonna sit there and guess it for you. Java Velocity lets you type
$object.Attributeand then it goes hunting for theAttribute,getAttribute,getattribute,isAttributemethods all on your behalf. in Perl Alloy? you can call$object.can('Attribute')to introspect the object yourself. do it manually, queen. π - escaping of variables is consistent. the Java Velocity spec is not. read that again. 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, which is giving chaos honestly. in Alloy, the"\\$email"would be"\$email"if email is not defined. consistent. predictable. we love that for us. β¨ - you can set items to null (undefined) in Alloy. according to the Java Velocity reference-guide, you'd have to configure Velocity to make that happen. if you want the other behavior (the non-Alloy one), you'd need to do
"#if($questionable)#set($foo=$questionable)#end". and here's the kicker: 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 even mention#literal, but the user-guide does. in Alloy you can use this instead:
#get('#foreach($a in [1..3]) $a #end')
we'll probably add the literal support at some point β but it will still have to parse the document, so unless you are using compile_perl, you will parse literal sections multiple times. keep that in mind. π
- there is no
"$velocityCount". use"$loop.count"instead. periodt. π - in Alloy, excess whitespace outside of the directive matters. the VTL user-guide mentions that all excess whitespace is gobbled up, but Alloy is not out here gobbling anything. Alloy supports the TT chomp operators instead β and these operators go just inside the open and close parenthesis of directives, like so:
#set(~ $a = 1 ~)
- in Alloy, division using
"/"is always floating point. always. no exceptions. if you want integer division, use"div". meanwhile in Java Velocity,"/"division is integer only if both numbers are integers. different strokes, bestie. π₯ - Perl doesn't support negative ranges. sad but true. however, arrays do have the
reversemethod, so you can absolutely still get where you're going:
#foreach( $bar in [-2 .. 2].reverse ) $bar #end
- in Alloy, arguments to macros are passed by value, not by name. and this is actually super easy to achieve with alloy β you just encase your arguments in single quotes and then
evalthe argument inside the macro. the velocity people claim this feature as a jealously guarded feature, which is a whole mood honestly. the author's first template system,"WrapEx", had the same feature β and it happened as an accident. it represents lazy software architecture and is difficult to optimize. πππ (not the accidental feature becoming a "jealously guarded feature" i'm crying)
π AUTHOR π
Paul Seamons <paul@seamons.com> β the main character who made all of this happen. π
π LICENSE π
This module may be distributed under the same terms as Perl itself.
okay bestie that's the whole page! π this was written by perl v5.38.2, dated 2024-03-07, and it's part of the Templa...elocity(3pm) / User Contributed Perl Documentation situation. slay, go forth, and remember: division is always floating point. no cap. πβ¨π¦
π¦ where this page comes from
- debian trixie: libtemplate-alloy-perl 1.022-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libtemplate-alloy-perl 1.022-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libtemplate-alloy-perl 1.022-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms