Answers.Body: <p>To answer your title question... macros in Craft 3 work exactly the same as they do in Craft 2. :)</p>
  
  <p>The problem you are hitting is here:</p>
  
  <pre><code>{{ macros sizedImage...
  </code></pre>
  
  <p>Seems like a straightforward typo. I'm assuming you meant to write it like this:</p>
  
  <pre><code>{{ macros.sizedImage...
  </code></pre>
  
  <p>For that reason (among others), I would recommend <em>not</em> naming your imported macros as "macros". It just invites confusion, and leads to silly typos like this one.</p>
  
  <p>Personally, I often name them "render" (though you can truly name them anything) because it's more obvious what's happening.</p>
  
  <pre><code>{% import 'macros/global' as render %}
  {{ render.sizedImage... }}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-01T01:48:32.883Z
Answers.Text: Thank you @Lindsey D. What an odd error, as I have those code snippets saved, but I guess they weren't right.
Answers.UserDisplayName: 4midori
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-31T16:07:15.023Z
Answers.LastActivityDate: 2018-05-31T16:07:15.023Z
Answers.UserDisplayName: Lindsey D
Body: <p>Here is what I am doing, but it's not working:</p>
  
  <p>In a template:</p>
  
  <pre><code>{% import 'macros/global' as macros %}
  {{ macros sizedImage(image, alt, 't600X450', 600, 450, link, 'someClass') }}
  </code></pre>
  
  <p>The I have a macro file with code like this:</p>
  
  <pre><code>{% macro sizedImage(img, alt, transform, declaredWidth, declaredHeight, link, class) %}
  ...bunch of code...
  {% endmacro %}
  </code></pre>
  
  <p>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.</p>
  
  <p>The error I get is:</p>
  
  <blockquote>
    <p>Twig Syntax Error – Twig_Error_Syntax
    Unexpected token "name" of value "sizedImage" ("end of print statement" expected).</p>
  </blockquote>
  
Tags: <craft3><macro>
Title: Just how do Macros work in Craft 3?
ThreadText: # Just how do Macros work in Craft 3?
  
  (Asked by: username_0 on 2018-05-31)
  
  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).
  
  **Tags:** craft3, macro
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-05-31. Score: 5 | Accepted answer
  
  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... }}
  
  ```
  
  > **Comments:**
  > **username_0**: Thank you @username_1. What an odd error, as I have those code snippets saved, but I guess they weren't right.  
  
  ---
  
  