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

[BUG] [Formatter] Incorrect indentation of custom template tags with a variable inside said template tag #572

Closed
3 tasks done
malo-malo opened this issue Mar 24, 2023 · 3 comments
Labels

Comments

@malo-malo
Copy link

System Info

  • OS: Ubuntu 20.04
  • Python Version 3.8.10
  • djLint Version 1.19.16
  • template language: django

Issue

I have a custom template tag flatblock (declared in the custom_blocks of my pyproject.toml), which isn't correctly indented when only a variable is inside it, whereas the block template tag is correctly indented in the same situation :

Before formatting

{% block title %}{{ title }}{% endblock title %}

{% flatblock title %}{{ title }}{% endflatblock title %}

After formatting

{% block title %}
    {{ title }}
{% endblock title %}

{% flatblock title %}
    {{ title }}{% endflatblock title %}

Note that if I use an html tag in the flatblock it will be correctly indented :

{% flatblock title %}
    <p>{{ title }}</p>
{% endflatblock title %}

How To Reproduce

Here is the content of my pyproject.toml

[tool.djlint]
require_pragma = true
profile = "django"
custom_blocks = "stage, cache, flatblock"
blank_line_after_tag = "extends, endblock, endflatblock"
max_line_length = 120
ignore = "H021,H023,H030,H031"
@malo-malo malo-malo added 🦠 bug Something isn't working 🧽 formatter labels Mar 24, 2023
@christopherpickering
Copy link
Contributor

@malo-cayocca sorry for the huge delay in looking into to this. I should have a release out in a bit.

as a temporary workaround you can add "endflatblock" to your list of custom blocks:

custom_blocks = "stage, cache, flatblock, endflatblock"

@malo-malo
Copy link
Author

No problem, that was still pretty quick in my opinion ! Thanks again for all your work on this project, it has proven to be quite useful !

christopherpickering pushed a commit that referenced this issue Apr 5, 2023
## [1.19.17](v1.19.16...v1.19.17) (2023-04-05)

### Bug Fixes

* **blocktrans:** allowed closing transblocks to be indented if they have a leading space ([d667273](d667273))
* **custom tags:** fixed issue where end tag for custom block was not de-indented ([fb8bf5e](fb8bf5e)), closes [#572](#572)
* **ignored code:** fixed formatting of ignore code inside django comment blocks ([120460d](120460d)), closes [#569](#569)
* **linter:** linter will now ignore {% raw %} {% endraw %} blocks ([2a6865e](2a6865e)), closes [#539](#539)
* **max line length:** fixes issues around max line length not fully respected on indented lines ([1ec6b29](1ec6b29)), closes [#580](#580)
* **preserving space:** misc improvements for the preserve leading space option ([03ee6f0](03ee6f0)), closes [#566](#566)
@christopherpickering
Copy link
Contributor

🎉 This issue has been resolved in version 1.19.17 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants