Velocimacros are functions that can be declared at the top of a template or context and reused as many times as you need. Really, the term “macro” doesn't do them justice, since with VTL you can use a wide swath of Java language features, and all that fun stuff can be used inside a #macro too.

 

While using macros in tiny scripts is probably a sign of overengineering, when I answer questions on the Marketo community I like to structure my code with the user-editable parts (i.e. site-specific strings) at the top and then a comment like ## No need to edit below this line!. (The goal being to make new/non-developers a little less frightened.)

 

So if at the end of a script you'll want to output a link (as is very common!) you might think about putting a macro at the top to call later...

Read the full post on TEKNKL :: Blog →