craftcms / cms

Build bespoke content experiences with Craft.
https://craftcms.com
Other
3.28k stars 635 forks source link

[4.x]: Cannot use "tag" Twig tag inside "nav" Twig tag #13304

Open piotrpog opened 1 year ago

piotrpog commented 1 year ago

What happened?

This code will throw error (note the "tag" Twig tag placed inside "nav").

{% set entries = craft.entries().section('pages').all() %}

<ul id="nav">
{% nav entry in entries %}

{% tag 'div' with {
   class: 'something',
} %}
some content 
{% endtag %}

    <li>
      <a href="{{ entry.url }}">{{ entry.title }}</a>
      {% ifchildren %}
        <ul>
          {% children %}
        </ul>
      {% endifchildren %}
    </li>
  {% endnav %}
</ul>

Craft CMS version

4.4.13

PHP version

8.1

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

-

i-just commented 1 year ago

Hi, thanks for reaching out. I’ve just run it on Craft 4.4.13, and the template renders as expected without errors. What error are you seeing with this code?