diff --git a/src/djlint/settings.py b/src/djlint/settings.py index 9f72f070..4fdc40fe 100644 --- a/src/djlint/settings.py +++ b/src/djlint/settings.py @@ -510,6 +510,7 @@ def __init__( | raw | blocktrans(?!late) | blocktranslate + | set(?!(?:(?!%}).)*=) """ + self.custom_blocks + r")" @@ -658,6 +659,7 @@ def __init__( | raw | blocktrans(?!late) | blocktranslate + | set(?!(?:(?!%}).)*=) """ + self.custom_blocks @@ -708,6 +710,7 @@ def __init__( | endblocktrans(?!late) | blocktranslate | endblocktranslate + | set(?!(?:(?!%}).)*=) """ + self.custom_blocks + r""") diff --git a/tests/test_nunjucks/test_set.py b/tests/test_nunjucks/test_set.py index 43d3c2e2..0d9f633b 100644 --- a/tests/test_nunjucks/test_set.py +++ b/tests/test_nunjucks/test_set.py @@ -122,6 +122,23 @@ ({}), id="indent py style list", ), + pytest.param( + ( + '{% set cta %}{% include "partials/cta.njk" %}
{% endset %}\n' + "{%-set posts = collections.docs-%}\n" + "{%asdf%}" + ), + ( + "{% set cta %}\n" + ' {% include "partials/cta.njk" %}\n' + "
\n" + "{% endset %}\n" + "{%- set posts = collections.docs -%}\n" + "{% asdf %}\n" + ), + ({}), + id="set block", + ), ]