Macros¶
Macros are comparable with functions in regular programming languages. They are useful to reuse template fragments to not repeat yourself.
Importing macros¶
In order to use a macro you need to import it first.
In this example we imported the footer_group
macro defined in footer_group.twig
file in @macros
namespace and the macro is now available under the footer_group
variable.
It is possible to change the variable name form imported macro to something else, for example group
:
Using macros¶
When the macro is imported, you can use it in your template.
Macros accept input parameters. In this example we pass the footerGroup
variable to the macro, which represents the FooterGroup object.