cms icon indicating copy to clipboard operation
cms copied to clipboard

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

Open piotrpog opened this issue 2 years ago • 1 comments

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

piotrpog avatar Jun 10 '23 12:06 piotrpog

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?

i-just avatar Jun 12 '23 09:06 i-just