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

Indentation in custom blocks #24

Closed
rixx opened this issue Sep 7, 2020 · 2 comments
Closed

Indentation in custom blocks #24

rixx opened this issue Sep 7, 2020 · 2 comments
Labels
bug Something isn't working

Comments

@rixx
Copy link

rixx commented Sep 7, 2020

Describe the bug

In Django at least, libraries can come with their own block-level tags. curlylint expects content in these tags to be indented to the same level as the tags themselves. I think we can agree that this behaviour is weird.

The better question is what else to expect. I could see both "enforce no indentation levels for unknown block tags" (because they may be whitespace-sensitive) and "enforce an additional indentation level" (as with tags such as {% block %}.

Reproducible demo

test.html:

{% blocktrans %}
    sdf
{% endblocktrans %}
{% someblock %}
    sdf
{% endsomeblock %}

If you run curlylint --rule "indent: 4" test.html:

test.html
0:0	Bad text indentation, expected 0, got 4	indent

Oh no! 💥 💔 💥
1 error reported

Despite the reported line number, this refers to the indentation in someblock – if you remove someblock, the error goes away, if you remove blocktrans, the error remains unchanged.

Side note, because I keep opening issues: This is a great project and I am extremely happy to have found it. Thank you for providing and maintaining it!

@rixx rixx added the bug Something isn't working label Sep 7, 2020
@thibaudcolas
Copy link
Owner

thibaudcolas commented Sep 8, 2020

Hey @rixx, I’m happy you’re finding this useful and taking the time to write such detailed reports 😄 . In this case, I think this might be the same issue as #6? To me an additional level would be better as the default, and I think I’d consider the lack of that level to be a bug.

For the "whitespace-sensitive" tags – do you have other examples than Django’s blocktrans / blocktranslate? I’m interested in making a linting rule that mandates using the trimmed attribute for these, because it’s a fairly common annoyance to have to translate insignificant whitespace in .po files. I’m happy to be told this isn’t that simple though, if there are cases where whitespace is valuable.

@rixx
Copy link
Author

rixx commented Sep 8, 2020

Ah, yes, this seems to be a duplicate of #6, sorry for missing this!

I'm all for having a linting rule mandating trimmed because occasionally I forget and then I'm very annoyed with myself. I don't know of other block level tags that respect whitespace, and while there might be some, you could always handle that as it comes up, I guess?

@rixx rixx closed this as completed Sep 8, 2020
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