djlint / djLint

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

[BUG] [Formatter] #931

Open TomFaulkner opened 1 month ago

TomFaulkner commented 1 month ago

System Info

Issue

Some includes are formatted in such a way that it breaks the include.

How To Reproduce

Format this:

    <script>
        {% include "shared/_base/components/toast.js" %}
    </script>

And the result is:

   <script>
        {
            % include "shared/_base/components/toast.js" %
        }
    </script>

With the whitespace between the brace and percent sign, Jinja doesn't process this include.

I am aware that this isn't ideal for how to use JS, and it should be a file hosted on the server, but I have this currently until I get other things setup.

JCWasmx86 commented 3 weeks ago

Those template expressions in JS need to be wrapped within

/* beautify ignore:start */
{% include "shared/_base/components/toast.js" %}
/* beautify ignore:start */

(Not ideal, but good enough)

TomFaulkner commented 1 week ago

Thanks!