-
-
Notifications
You must be signed in to change notification settings - Fork 84
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
Jinja formatting issues #715
Conversation
… whole of the file - Added code to handle extra spacing inside the double quotes, as well as ensure only single quotes - It also removes any extra white space based on teh word boundaries
…e quotes on the outside
✅ Deploy Preview for djlint ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Note: This forces double quotes on the outside and single quotes inside. |
…ach section and correctly modify the inner quotes - This will always prioritize what ever the user had set on the outer quotes and will only activate for jinja templates
Update: New code is stable, passes all tests, allows the linter to detect the outer most quotes and apply changes to the inner most to prevent vscode and syntax errors as well as handles spacing issues that can be caused by using the built in formatter in vscode and then using djlint |
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #715 +/- ##
==========================================
- Coverage 95.35% 93.67% -1.69%
==========================================
Files 16 16
Lines 1033 1059 +26
Branches 278 285 +7
==========================================
+ Hits 985 992 +7
- Misses 34 50 +16
- Partials 14 17 +3
☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this, I appreciate it. I put a few comments > if you don't want to invest more time you can leave as is and I can pick it up sometime.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, instead of changing the test here, can you just do 2 tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nunjucks is pretty much identical to jinja, and anyone else using quotes can benefit from this :) Do you mind to remove the the profile check?
aren't cases like this still going to confuse vs code?
The other odd case is where there is a line break:
I think if we move this down to where we do the set tag formatting, it will be able to work w/ wrapping.
At the same time it might be good to add a flag --single-quote-templatetags, vs a --single-quote tag we can add later on for just html attributes.
Thanks for starting this, if you don't wanna invest more time you can leave as is and I can pick it up sometime.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey sorry for the delay, yep I think this is the place- it is where the contents of functions are updated.
I'm free to discord call early afternoon today if it's good for you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to add me on discord jlw_4049
so we can talk quicker
Sorry for the delay here. I updated the test case a bit, and added a more complex test. Can every see if they agree w/ this code:
|
✅ Deploy Preview for djlint canceled.
|
Hey, just checking what is missing here before merging? I am using the ident.py changes locally and seems to be working just fine |
The post I made above yours is the last I messed with it. The repository owner isn't maintaining it right now to my understanding. There is @monosans I believe but haven't heard anything on this subject from him. Perhaps he could shed some light on a solution to this. |
🎉 This PR is included in version 1.34.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Hi @christopherpickering, I just updated the package to the latest release, tks for your incredible work! However this formatting issue is still present. Just as an example: code: <link rel="stylesheet" href="{{ static('css/output.css') }}?{{ now() .strftime('%d-%m-%Y') }}" /> gets formatted into: <link rel="stylesheet" href="{{ static("css/output.css") }}?{{ now().strftime('%d-%m-%Y') }}" /> As a workaround I am manually changing ident.py with https://github.com/jessielw/djLint/blob/7b7e504de721e51cf4c5dcc8115540145a8eac23/src/djlint/formatter/indent.py Is there any reason why this changes were not included in the new releases? |
Seems like I've merged branches incorrectly. Will take a look right now. FYI Christopher is not maintaining djLint anymore. |
Oh so I will rephrase then, tks you @monosans for your work! Got it! |
I'm pretty sure I've merged everything correctly. Need to find the reason why it doesn't work. |
The issue is with the commit: "- Add the ability to detect what ever the outer most quotes was for e…" That one re-introduced the bug. I am using this script to fix it locally for the new releases: #!/bin/bash
# URL to fetch the new contents from
# Commit: WORKING - "- Added some regex to ensure we have double quoted attributes for the…"
URL="https://raw.githubusercontent.com/jessielw/djLint/7b7e504de721e51cf4c5dcc8115540145a8eac23/src/djlint/formatter/indent.py"
# Commit: BROKEN - "- Add the ability to detect what ever the outer most quotes was for e…"
# URL="https://raw.githubusercontent.com/jessielw/djLint/e9dc2aaf7c977def61af6c75fd0b7fc87634d198/src/djlint/formatter/indent.py"
# Find all indent.py files under **/djlint/formatter/ directories
files=$(find . -type f -path "*/djlint/formatter/indent.py")
# Loop over each found file and replace its contents
for file in $files;
do
echo "Replacing contents of $file"
curl -s $URL -o "$file"
done
echo "Replacement complete." |
Pull Request Check List
Resolves: #issue-number-here