trivago / prettier-plugin-twig-melody

Code formatting plugin for Prettier which can handle Twig/Melody templates
Apache License 2.0
155 stars 35 forks source link

Unknown bug #1 #97

Open ddv88 opened 2 years ago

ddv88 commented 2 years ago
[error] Error: ERROR: Expected element start
[error]   20 |                         </ul>
[error]   21 |                     {% endif %}
[error] > 22 |                 </div>
[error]      |                  ^
[error]   23 |             {% endfor %}
[error]   24 |         </div>
[error]   25 |     </div>
[error]
[error] Unexpected closing "div" tag. Seems like your DOM is out of control.
<footer class="footer">
    <div class="container">
        <div class="row position-absolute w-100 pt-3 pb-3">
            {% for item in links %}
                <div class="col-md-4 col-lg-4">
                    {% if item.child %}
                    <div>{{ t(item.text|upper) }}</div>
                    <ul class="list-unstyled">
                        {% for child in item.child %}
                            <li class="nav-item">
                                <a class="nav-link {{ child.class }}" href="{{ href(child.link) }}">
                                    {{ t(child.text) }}
                                </a>
                            </li>
                        {% endfor %}
                        {% else %}
                            <div>{{ t(item.text) }}</div>
                       </ul>
                 {% endif %}
                </div>
            {% endfor %}
        </div>
    </div>
</footer>
jamiematrix commented 2 years ago

Not sure if it's related but your closing </ul> is outside of the {% endif %} but the opening <ul> is inside the {% if %}

ddv88 commented 2 years ago

Not sure if it's related but your closing </ul> is outside of the {% endif %} but the opening <ul> is inside the {% if %}

It's just my copy/paste mistake.

karlschwaier commented 2 years ago

I can't reproduce this bug. Formatting worked with your example code. Anyway you should move up your into the first part of the if to get valid HTML.