-
-
Notifications
You must be signed in to change notification settings - Fork 86
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] Jinja variable within a <script> tag #613
Comments
hey @davidbgk the js formatter is from jsbeautify and does not support template syntax yet. You'll hve to run w/out the --format-js flag to make that work. does that help? |
@christopherpickering oh I get it, thanks! I do confirm that it doesn't try to reformat the block if I remove the I'm still wondering why ignoring that whole HTML block leads to its evaluation though 🤔 that would have come handy for my case. Feel free to close the issue if you think it's not a real problem given that the main issue is explained! |
Hmm if you tried to ignore the block in djlint, it should have ignored it. Can you put the code you tried, and I will take a look deeper. |
I tried that one and other combinations (
|
Hello.
|
It looks like the issue is that the |
I confirm the fix works for my case on the |
## [1.27.2](v1.27.1...v1.27.2) (2023-05-11) ### Bug Fixes * **formatter:** fixed an edge case wild regex grab ([0d57e75](0d57e75)), closes [#640](#640) * **formatter:** fixed formatting of plural tag in blocktrans ([92c083b](92c083b)), closes [#641](#641) * **formatter:** fixed js/css being formatted even inside ignored blocks ([cbf5796](cbf5796)), closes [#613](#613) * **linter:** fixed a few false positives/missing positives, added tests ([30f8d31](30f8d31)), closes [#643](#643) [#642](#642) * **linter:** fixed false postive in alpinejs tags for H037 ([6520f63](6520f63)), closes [#639](#639)
🎉 This issue has been resolved in version 1.27.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
I'm currently using v1.28 of djlint but the problem still seems to work with javascript code. /* beautify preserve:start */ --> Works |
@nexgen please open a new issue with a code example. |
System Info
Issue
First time user, I tried to reformat a template containing that code:
And it always produces:
Whatever the kind of ignoring comment I put around that part of the HTML (which is probably another bug(?).
How To Reproduce
The command I use is the following:
djlint templates --profile=jinja --reformat --format-css --indent-css 2 --format-js --indent-js 2 --indent 2
I tried with or without the script's attributes (
id
andtype
) and there is no difference.Hope it helps! (and I can provide more details on demand)
The text was updated successfully, but these errors were encountered: