Just how do Macros work in Craft 3? Here is what I am doing, but it's not working:

In a template:

{% import 'macros/global' as macros %}
{{ macros sizedImage(image, alt, 't600X450', 600, 450, link, 'someClass') }}


The I have a macro file with code like this:

{% macro sizedImage(img, alt, transform, declaredWidth, declaredHeight, link, class) %}
...bunch of code...
{% endmacro %}


It's not clear from Craft's documentation what I should be doing differently. I did note that macros have to be included in the template where they are called, instead of a parent template, and that is fixed.

The error I get is:


  Twig Syntax Error – Twig_Error_Syntax
  Unexpected token "name" of value "sizedImage" ("end of print statement" expected).
To answer your title question... macros in Craft 3 work exactly the same as they do in Craft 2. :)

The problem you are hitting is here:

{{ macros sizedImage...


Seems like a straightforward typo. I'm assuming you meant to write it like this:

{{ macros.sizedImage...


For that reason (among others), I would recommend not naming your imported macros as "macros". It just invites confusion, and leads to silly typos like this one.

Personally, I often name them "render" (though you can truly name them anything) because it's more obvious what's happening.

{% import 'macros/global' as render %}
{{ render.sizedImage... }}