Is it possible to dynamically invoke a macro in Twig? For example, here is a template and macro called "group" that creates a group of buttons using the buttons array argument. There are also two other macros: save and delete to create save and delete buttons.
{
This works fine with array buttons:
{% import "::buttons.html.twig" as buttons %} {% set items = [buttons.save, buttons.delete] %} {{ buttons.group(items) }}
But I would like to pass macros to group macro:
{% import "::buttons.html.twig" as buttons %} {{ buttons.group(['save', 'delete']) }}
and automatically invoke save and delete macros. Is this possible and how?
gremo source share