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] Replaces kwargs with empty {} #1030

Open
Diegovsky opened this issue Nov 21, 2024 · 2 comments
Open

[BUG] [Formatter] Replaces kwargs with empty {} #1030

Diegovsky opened this issue Nov 21, 2024 · 2 comments
Labels
🦠 bug Something isn't working 🧽 formatter

Comments

@Diegovsky
Copy link

Diegovsky commented Nov 21, 2024

System Info

  • OS: Arch Linux

  • Python Version (python --version): 3.12.7

  • djLint Version (djlint --version): djlint, version 1.36.1

  • template language: e.g. mustache: jinja2

Issue

Djlint replaces kwargs with empty {} inside macro definitions.

How To Reproduce

Here's a sample from our source code:

{% macro _expand_attrs(attrs) %}
    {% for attr, val in attrs.items() -%}{{ attr }}="{{ val }}"{% endfor %}
{% endmacro %}

{% macro button(text, _tag="button", class="") %}
    <{{- _tag }} class="p-[10px] bg-[#FF7A00] rounded-[8px] text-white
    transition duration-150 transition-color disabled:opacity-50 {{class}}" {{ _expand_attrs(kwargs) }}>
    {% if caller is defined %}
        {{ caller() }}
    {% else %}
        {{ text }}
    {% endif %}
    </{{- _tag -}}>
{% endmacro %}


{% macro link_button(text, href='') %}
    {{ button(text, type="link", _="on click go to url '"~href~"'", **kwargs) }}
{% endmacro %}

Upoon formatting with djlint, it replaces kwargs uses with {}

@Diegovsky Diegovsky added 🦠 bug Something isn't working 🧽 formatter labels Nov 21, 2024
@oliverhaas
Copy link
Contributor

oliverhaas commented Nov 22, 2024

Using the online djlint formatter, I can't reproduce the issue.

Which "kwarg" do you mean? Both "kwargs"?

Do you have any other settings?

@Diegovsky
Copy link
Author

Diegovsky commented Nov 23, 2024

Hey there, thanks for the fast response :)

I meant every kwargs use was replaced with an empty dict. Both in link_button and in button.

I haven't tried the web formatter, but it is occourring in the CLI. I'm not sure if this is relevant, but my file extension is .html.j2.

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