djlint / djLint

✨ HTML Template Linter and Formatter. Django - Jinja - Nunjucks - Handlebars - GoLang
https://djLint.com
GNU General Public License v3.0
687 stars 84 forks source link

[BUG] [Linter] Apostroph in string leads to T027 #141

Open dyve opened 2 years ago

dyve commented 2 years ago

System Info

Issue

Apostroph in string leads to T027 ("Unclosed string found in template syntax").

How To Reproduce

Lint this template

{% load i18n %}

{% trans "Check box if you're interested in this location." %}

Note that this leads to a report: T027 XX:8 Unclosed string found in template syntax. {% trans "Check box

Configuration

# pyproject.toml
[tool.djlint]
# Reference: https://djlint.com/djlint/rules.html
profile = "django"
ignore = "H017,H019,T003,T002,H023,H014,H008,T028,H021,T001,H006,H013,H022"
blank_line_after_tag = "load,extends,include"
max_line_length = 120
christopherpickering commented 2 years ago

:tada: This issue has been resolved in version 1.0.0 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket:

monosans commented 2 years ago

This issue reappeared in https://github.com/Riverside-Healthcare/djLint/commit/946b8ad7152b098ddc2489a52bc668ba48737445.

christopherpickering commented 2 years ago

@monosans ah, thanks, I see in the test it is missing the --profile flag, which is why this test is passing.

christopherpickering commented 2 years ago

:tada: This issue has been resolved in version 1.9.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

travenin commented 2 years ago

I am getting similar error with version 1.9.4 when there are odd number (but more than one) of apostrophes. For example:

{% trans "Click 'submit' if you know what you're doing." %}

I get an error Unclosed string found in template syntax. {% trans "Click 'sub (T027).

e0da commented 3 weeks ago

This still occurs in 1.35.2. Here's an example:

{% '', "'" %}
{% 'foo', "can't" %}

To work around it, I use " for everything in this case, except the literal ' that I need in my string.

{% "foo", "can't" %}