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] Expression inside tag forces formatting to one-line #806

Open
GPla opened this issue Jan 20, 2024 · 1 comment
Open

[BUG] [Formatter] Expression inside tag forces formatting to one-line #806

GPla opened this issue Jan 20, 2024 · 1 comment
Labels
🦠 bug Something isn't working 🧽 formatter

Comments

@GPla
Copy link

GPla commented Jan 20, 2024

System Info

  • OS: Windows 10.0.19045
  • Python Version 3.11.5
  • djLint Version 1.34-1
  • template language: jinja

Issue

An expression {{ some_function(arg) }} inside a tag formats everything to a single-line, while without the attributes are split onto mutliple lines.

How To Reproduce

Create an issue.html.jinja2 and format it with djLint.

{# correctly formatted #}
<button class="btn p-1 m-1"
        id="a-very-very-very-long-id"
        aria-label="some button">Press me!</button>


{# forced to one-line when adding expression #}
<button class="btn p-1 m-1" id="a-very-very-very-long-id" aria-label="some button" {{ attributes(attr) }}>Press me!
</button>
@GPla GPla added 🦠 bug Something isn't working 🧽 formatter labels Jan 20, 2024
@nitsujri
Copy link

Similarly, I have

              <a
                class="dropdown-item{% if item.class %}{{item.class}}{% endif %}"
                href="{{ item.url }}"
                {% if item.html_attrs %} {% for attr, value in item.html_attrs.items %}{{ attr }}="{{ value }}"{% endfor %} {% endif %}
                {% if item.target %}target="{{ item.target }}"{% endif %}
                {% if item.confirm %}onclick="return confirm('{{ item.confirm }}');"{% endif %}
              >
                <i class="dropdown-item-icon"></i>{{ item.label }}
              </a>

gets auto formatted to:

              <a class="dropdown-item{% if item.class %}{{ item.class }}{% endif %}" href="{{ item.url }}" {% if item.html_attrs %} {% for attr, value in item.html_attrs.items %}{{ attr }}="{{ value }}"{% endfor %} {% endif %} {% if item.target %}target="{{ item.target }}"{% endif %} {% if item.confirm %}onclick="return confirm('{{ item.confirm }}');"{% endif %}>
                <i class="dropdown-item-icon"></i>{{ item.label }}
              </a>

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

2 participants