Skip to content

Can't get twig filter in macros #578

@damsfx

Description

@damsfx

Winter CMS Build

1.2

winter/storm                        dev-wip/1.2 91993e2
winter/wn-backend-module            dev-wip/1.2 0258f85
winter/wn-cms-module                dev-wip/1.2 a998ed7
winter/wn-system-module             dev-wip/1.2 c5295ca
twig/twig                           v3.4.1

PHP Version

8.0

Database engine

MySQL/MariaDB

Plugins installed

No response

Issue description

Getting an error when using |page twig filter in a macro.

An exception has been thrown during the rendering of a template ("Undefined array key "this"").

Steps to replicate

composer create-project wintercms/winter winter12 "dev-wip/1.2 as 1.2"
php artisan winter:install
php artisan winter:env
php artisan winter:up

Then add {{ 'plugins' | page }} in default layout or home page.
Getting link to plugins page is ok.

If the same filter is call from within a macro, it fails.
Add a macro to layout and calling it :

{% macro test() %}
    {{ 'plugins' | page }}
{% endmacro test %}
{% import _self as home %}

{{ home.test() }}

Fall in an error.

Workaround

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions