Skip to content

[4.x, 5.x]: macros with a variable starting with an underscore don't work (known and fixed Twig issue) #18225

@Dollhopf

Description

@Dollhopf

What happened?

Description

Twig macro variables don't work properly when starting with an underscore. This Twig issue is only present in Twig v 3.15.0 and is fixed in the next version 3.16.0

Steps to reproduce

  1. Create a macro with a variable that starts with an underscore:
{% macro foo(_bar) %}
  {{ _bar|default('NOPE') }}
{% endmacro %}
  1. Call macro with set variable:
{{ _self.foo('It works') }}

Expected behavior

It works

Actual behavior

NOPE

Craft CMS version

4, 5

PHP version

No response

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions