Skip to content

{% nocache %} seems incompatible with {% embed %} #22

@nstCactus

Description

@nstCactus

Description

Using the {% nocache %} around an {% embed %} tag throws a yii\base\ErrorException:

Cannot declare class __TwigTemplate_58ca26ca050e28ccd1000e621e244e86d4395a3d535ac28fb668ef8f85a11918, because the name is already in use

Steps to reproduce

To reproduce, create the following templates and navigate to /nocache.

templates/nocache/index.twig:

{% nocache %}
    {% embed 'nocache/_list.twig' with { heading: 'Drinks' } %}
        {% block listItems %}
            {% include 'nocache/_item.twig' with { name: 'Beer' } %}
            {% include 'nocache/_item.twig' with { name: 'Orange juice' } %}
            {% include 'nocache/_item.twig' with { name: 'Water' } %}
        {% endblock %}
    {% endembed %}
{% endnocache %}

_templates/nocache/list.twig:

<h1>{{ heading }}</h1>
<ul>
    {% block listItems %}{% endblock %}
</ul>

_templates/nocache/item.twig:

<li>{{ name }}</li>

Additional information

  • No-Cache version: 2.0.6
  • Craft CMS version: 3.5.16
  • PHP version: 7.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions