djlint / djLint

✨ HTML Template Linter and Formatter. Django - Jinja - Nunjucks - Handlebars - GoLang
https://djLint.com
GNU General Public License v3.0
686 stars 84 forks source link

[BUG] [Formatter] Macro tags are not correctly formatted #773

Closed KrappRamiro closed 8 months ago

KrappRamiro commented 1 year ago

System Info

Issue

macro tags are not correcly formatted.

It formats to this

{# templates/macros/header.html #}
{% macro header(logo_url) %}
    <header class="header">
        <div class="header__logo">
            <img class="header__logo-image" alt="Email Sharer" src="{{ logo_url }}">
        </img>
    </div>
</header>
{% endmacro %}

when it should format to this

{# templates/macros/header.html #}
{% macro header(logo_url) %}
    <header class="header">
        <div class="header__logo">
            <img class="header__logo-image" alt="Email Sharer" src="{{ logo_url }}">
            </img>
        </div>
    </header>
{% endmacro %}

How To Reproduce

open a file called header.html, add the code mentioned above, and run djlint header.html --reformat

welcome[bot] commented 1 year ago

Thanks for opening your first issue here!

christopherpickering commented 10 months ago

I think the issues is from your </img> tag. Normally img tags are self closing. If this is your normaly style, you can add img as a custom html tag in your config.