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] enabling preserve leading space indents jinja2-comments and jinja2 set commands wrong #1073

Open
chris240189 opened this issue Dec 13, 2024 · 0 comments
Labels
🦠 bug Something isn't working 🧽 formatter

Comments

@chris240189
Copy link

System Info

  • OS: Ubuntu 24.04
  • Python Version 3.12.3
  • djLint Version 1.36.3
  • template language: jinja

Issue

I am trying to write a jinja2 template for networking equipment (arista switches, more or less cisco CLI) using vscode.
I installed the dlint extension and enabled "preserve leading spaces".
Leading spaces on my switch config code are preserved.
However, comments that would need an indent (inside a if-clause) get intended over and over on every file save (as vscode formats on save).
Also jinja2 set commands will not get indented at all and will be put to the start of the line.

How To Reproduce

{% if condition %}
   {# aaa #}
   {%- set varx = "aaa" %}
   aaa
{% endif %}

run
djlint <filename> --preserve-leading-space --reformat on the snippet once.

results in:

{% if condition %}
       {# aaa #}
{%- set varx = "aaa" %}
   aaa
{% endif %}

run it a few times and you get

{% if condition %}
                               {# aaa #}
{%- set varx = "aaa" %}
   aaa
{% endif %}
@chris240189 chris240189 added 🦠 bug Something isn't working 🧽 formatter labels Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🦠 bug Something isn't working 🧽 formatter
Projects
None yet
Development

No branches or pull requests

1 participant