API / Apache Velocity Interview questions
What is a Velocimacro (#macro directive)?
A Velocimacro is a reusable block of VTL defined once with #macro and then invoked like a function elsewhere in templates. It's Velocity's main mechanism for avoiding copy-pasted markup.
#macro(greet $name $formal) #if($formal) Dear $name, #else Hi $name! #end #end #greet("Alex" true) #greet("Sam" false)
Macros can be defined locally at the top of a single template (visible only within that template by default) or placed in a shared library file registered through the velocimacro.library property, which makes them available across every template the engine renders.
More Related questions...