Expecting closing tag for the "macro

Created on 1 July 2024, 3 days ago

Problem/Motivation

Problem/Motivation

The Extra Field module encounters a syntax error in the `di.twig` file when running the `test:code` task using Lullabot Drainpipe. This issue disrupts the development workflow and prevents successful linting of the code.

Steps to reproduce

  1. Install the Extra Field module version 8.x-2.3.
  2. Run the Drainpipe task `test:code`.
  3. Observe the following error message:
  4.   [test:lint]   ERROR  in web/modules/contrib/extra_field/src/Generators/lib/di.twig (line 5)
      [test:lint]       3      {% endmacro %}
      [test:lint]       4      {% macro use(services) %}
      [test:lint]   >>  5        {% sort %}
      [test:lint]   >> Unexpected "sort" tag (expecting closing tag for the "macro" tag defined near line 5). 
      [test:lint]       6          {% for service in services %}
      [test:lint]       7      use {{ service.type }};
      

Proposed resolution

Correct the Twig template in `di.twig` to remove the invalid `{% sort %}` tag and ensure all macro blocks are properly closed. The corrected version of the file should look like this:

{% macro arguments(services) %}
  {% for service_id, service in services %}'@{{ service_id }}'{{ loop.last ? '' : ', ' }}{% endfor %}
{% endmacro %}

{% macro use(services) %}
  {% for service in services %}
use {{ service.type }};
  {% endfor %}
{% endmacro %}

{% macro properties(services) %}
  {% for service in services %}
  /**
   * {{ service.description }}
   *
   * @var \{{ service.type }}
   */
  protected ${{ service.name|camelize(false) }};{{ loop.last ? '' : "\n\n" }}
  {%- endfor %}
{% endmacro %}

{% macro annotation(services) %}
  {% for service in services %}
   * @param \{{ service.type }} ${{ service.name }}
   *   {{ service.description }}{{ loop.last ? '' : "\n" }}
   {%- endfor %}
{% endmacro %}

{% macro signature(services) %}
  {% for service in services %}{{ service.short_type }} ${{ service.name }}{{ loop.last ? '' : ', ' }}{% endfor %}
{% endmacro %}

{% macro assignment(services) %}
  {% for service in services %}
    $this->{{ service.name|camelize(false) }} = ${{ service.name }};{{ loop.last ? '' : "\n" }}
  {%- endfor %}
{% endmacro %}

{% macro container(services) %}
  {% for service_id, service in services %}
      $container->get('{{ service_id }}'){{ loop.last ? '' : ",\n" }}
  {%- endfor %}
{% endmacro %}

Remaining tasks

  • Review all Twig templates in the module for similar issues.
  • Make necessary corrections.
  • Submit a patch for review.
πŸ› Bug report
Status

Active

Version

2.3

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States linwilvic

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024