Macros can be placed directly inside of your plugin within the conf/macros-ext.vm file. If you declare a macro that already exists the previous macro will be commented out and your new version of the macro will be used.
Custom macros can be written here as in the following example:
#macro (newMacro $newMacroParameter) Macro Code written here (or another file with macro code can be parsed or included) #end
After creating the custom macro, and saving it to the recommended .vm file, it can then be called from any piece of content, container, or template as any other macro:
While it is possible to add macros to any velocity page or file, it is important that you add all Velocity macros to files with a .vm extension, to ensure that your macros are cached properly. Inclusion of macros in pages or in files with extensions other than .vm (including .vtl files that contain other Velocity vode) may cause your pages to render incorrectly.