4

I was looking at various Drupal core twig templates to get an idea of how menus are rendered and I came across this line in menu--toolbar.html.twig:

{{ link(item.title, item.url) }}

Is link a macro? If so, where is it defined? It doesn't appear to be a feature of twig. I couldn't find it by searching the D8 codebase.

8

It's a Twig_SimpleFunction, rather than a macro. It's registered with Twig in \Drupal\Core\Template\TwigExtension::getFunctions.

Its callback method is \Drupal\Core\Template\TwigExtension::getLink .

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.