Answers.Body: <p>I think you need to reference a macro name inside of your <code>_common/_helpers</code> file.</p>
  
  <p>For example:</p>
  
  <pre><code>{{ helpers.input('username') }}
  </code></pre>
  
  <p>That would output a macro called <code>input</code>:</p>
  
  <pre><code>{% macro input(name, value, type = "text", size = 20) %}
      &lt;input type="{{ type }}" name="{{ name }}" value="{{ value|e }}" size="{{ size }}" /&gt;
  {% endmacro %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-09-05T11:17:35.367Z
Answers.LastActivityDate: 2019-09-05T11:17:35.367Z
Answers.UserDisplayName: Alex Roper
Body: <p>I'm trying to upgrade my website to Craft 3, so I've imported all template files and installed the necessary plugins, but I can't deal with one error.</p>
  
  <p>I've got a template named <code>_layout.twig</code>, and the first line used to import macros from other file called <code>_helpers.twig</code>. For some reason this doesn't work on Craft 3 - I checked in <a href="https://twig.symfony.com/doc/2.x/tags/macro.html#importing-macros" rel="nofollow noreferrer">Twig documentation</a> and it seems that everything is correct. I reviewed the changes in Craft 3 but didn't find anything related there. Running Craft 3.3 with Twig 2.11.3.</p>
  
  <p><strong>_layout.twig</strong></p>
  
  <pre><code>{% import '_common/_helpers' as helpers %}
  {{ helpers }}
  </code></pre>
  
  <p><strong>Error</strong></p>
  
  <blockquote>
    <p>Twig Runtime Error – Twig\Error\RuntimeError
    Variable "helpers" does not exist. </p>
    
    <p>in /craft3/templates/_layout.twig at line 2</p>
  </blockquote>
  
  <p>Any ideas what can be the issue here? </p>
  
Tags: <templating><craft3>
Title: Importing Macros doesn't work
ThreadText: # Importing Macros doesn't work
  
  (Asked by: username_0 on 2019-09-05)
  
  I'm trying to upgrade my website to Craft 3, so I've imported all template files and installed the necessary plugins, but I can't deal with one error.
  
  I've got a template named `_layout.twig`, and the first line used to import macros from other file called `_helpers.twig`. For some reason this doesn't work on Craft 3 - I checked in [Twig documentation](https://twig.symfony.com/doc/2.x/tags/macro.html#importing-macros) and it seems that everything is correct. I reviewed the changes in Craft 3 but didn't find anything related there. Running Craft 3.3 with Twig 2.11.3.
  
  **\_layout.twig**
  
  ```
  {% import '_common/_helpers' as helpers %}
  {{ helpers }}
  
  ```
  
  **Error**
  
  > Twig Runtime Error – Twig\Error\RuntimeError
  > Variable "helpers" does not exist.
  >
  > in /craft3/templates/\_layout.twig at line 2
  
  Any ideas what can be the issue here?
  
  **Tags:** templating, craft3
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-09-05. Score: 4 | Accepted answer
  
  I think you need to reference a macro name inside of your `_common/_helpers` file.
  
  For example:
  
  ```
  {{ helpers.input('username') }}
  
  ```
  
  That would output a macro called `input`:
  
  ```
  {% macro input(name, value, type = "text", size = 20) %}
      <input type="{{ type }}" name="{{ name }}" value="{{ value|e }}" size="{{ size }}" />
  {% endmacro %}
  
  ```
  
  
  ---
  
  