Skip to content

Commit

Permalink
feat(formatter): format set blocks
Browse files Browse the repository at this point in the history
closes #646
  • Loading branch information
christopherpickering committed May 18, 2023
1 parent 17faf5f commit d88371c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/djlint/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,7 @@ def __init__(
| raw
| blocktrans(?!late)
| blocktranslate
| set(?!(?:(?!%}).)*=)
"""
+ self.custom_blocks
+ r")"
Expand Down Expand Up @@ -658,6 +659,7 @@ def __init__(
| raw
| blocktrans(?!late)
| blocktranslate
| set(?!(?:(?!%}).)*=)
"""
+ self.custom_blocks
Expand Down Expand Up @@ -708,6 +710,7 @@ def __init__(
| endblocktrans(?!late)
| blocktranslate
| endblocktranslate
| set(?!(?:(?!%}).)*=)
"""
+ self.custom_blocks
+ r""")
Expand Down
17 changes: 17 additions & 0 deletions tests/test_nunjucks/test_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,23 @@
({}),
id="indent py style list",
),
pytest.param(
(
'{% set cta %}{% include "partials/cta.njk" %}<div></div>{% endset %}\n'
"{%-set posts = collections.docs-%}\n"
"{%asdf%}"
),
(
"{% set cta %}\n"
' {% include "partials/cta.njk" %}\n'
" <div></div>\n"
"{% endset %}\n"
"{%- set posts = collections.docs -%}\n"
"{% asdf %}\n"
),
({}),
id="set block",
),
]


Expand Down

0 comments on commit d88371c

Please sign in to comment.