Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stumbles over… I don't know what ;) #62

Closed
Natureshadow opened this issue Mar 3, 2021 · 3 comments
Closed

Stumbles over… I don't know what ;) #62

Natureshadow opened this issue Mar 3, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@Natureshadow
Copy link

Describe the bug

I tried curlylint on our set of Django templates, and it stumbled over some things I cannot really explain. One example is this template:

https://edugit.org/AlekSIS/official/AlekSIS-Core/-/blob/d579eec21675787347c7e7d4c2862d9d75030b0a/aleksis/core/templates/dynamic_preferences/sections.html

curlyprint complains:

aleksis/core/templates/dynamic_preferences/sections.html
12:2    Parse error: expected 'li' at 12:2      parse_error

It shows similar errors for other templates, but this is a very simple one.

Which terms did you search for in the documentation and issue tracker?

"parse", mainly.

Environment

I am not sure what Draft.js has to do with this, neither what relevance my browser has to do with it, as I run curlylint on the shell.

I use curlylint 0.12.0 from PyPI under Python 3.9 on Debian bullseye/sid.

Steps to reproduce

  1. pip3 install curlylint
  2. wget https://edugit.org/AlekSIS/official/AlekSIS-Core/-/raw/d579eec21675787347c7e7d4c2862d9d75030b0a/aleksis/core/templates/dynamic_preferences/sections.html
  3. curlylint sections.html

Expected behavior

Template is lint-clean.

Actual behavior

curlylint throws above parse error.

Reproducible demo

{% load i18n %}
<ul class="tabs">
  <li class="tab ">
    {% for section in registry.section_objects.values %}
      <li class="tab">
        <a class="{% if active_section == section.name %}active{% endif %}"
           href="{% url registry_url section.name %}"
           target="_self">
          {{ section.verbose_name }}
        </a>
      </li>
    {% endfor %}
</ul>
@Natureshadow Natureshadow added the bug Something isn't working label Mar 3, 2021
@thibaudcolas
Copy link
Owner

Hey @Natureshadow, thank you for the detailed report!

Draft.js has nothing to do with this :) I just forgot to change that part of the issue template when setting up the repository.

Looking at your example, this looks like it might just be due to the extra li on line 3?

{% load i18n %}
<ul class="tabs">
-  <li class="tab ">
    {% for section in registry.section_objects.values %}
      <li class="tab">
        <a class="{% if active_section == section.name %}active{% endif %}"
           href="{% url registry_url section.name %}"
           target="_self">
          {{ section.verbose_name }}
        </a>
      </li>
    {% endfor %}
</ul>

The parser is quite strict and will fail on templates that have mismatched start and end tags, which is usually what you want, but makes for cryptic error messages.

@Natureshadow
Copy link
Author

Oh dear. You are absolutely correct. I was focused too much on what the error explicitly said.

Sorry for the noise ;)!

@thibaudcolas
Copy link
Owner

Great, no problem at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants