-
Notifications
You must be signed in to change notification settings - Fork 14
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
Format html templates using djlint #1350
Conversation
02d8cd1
to
f85d195
Compare
Co-authored-by: rmccar <[email protected]>
Co-authored-by: rmccar <[email protected]>
Co-authored-by: rmccar <[email protected]>
Co-authored-by: rmccar <[email protected]>
Co-authored-by: rmccar <[email protected]>
Co-authored-by: rmccar <[email protected]>
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.
The changes look good! There are a few blocks that djlint could be switched back on (mentioned in the comments), but I'm not sure if that might litter the files a bit too much with the 'on/off' stuff, or even if it might be overkill? (Confirmed not possible)
Just a quick question too, would we be adding the djlint dependency, readme doc, GitHub Actions etc as part of this ticket?
Based on the conversations I had with @MebinAbraham my understanding is it is not part of this ticket, this is just to format the files. |
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.
Looks good to me! 👍
What is the context of this PR?
We want to ensure that code is consistent across all our HTML templates in Runner. It will make it easier to maintain code over time, as the code is formatted uniformly and is easier to read and understand.
Files are formatted using djlint, some config was added, DS components are all set to be ignored since djlint cannot cope with their nesting. They were nested manually using a style that improves readability.
Some html tags content in some html templates had to be placed in strings to avoid multiple lines that will cause issues with html rendering in our integration tests. Some inconsistency may be present as this is the first time we try to force uniform formatting in all the html templates.
To run djlint install using
npm install
orpipenv install
and run:djlint ./templates --reformat --profile=jinja
- to formator
djlint ./templates --profile=jinja
- to lintYou can optionally add formatting of JavaScript since we have some tiny snippets but the main JS block in
_base.html
cannot be formatted since it uses Javascript and combines it withjinja
vars.djlint ./templates --reformat --profile=jinja --format-js
How to review
Some of the whitespace, new line and nesting rules are debatable so check if you agree.
Check djlint configuration doc for possible improvements that can be added. There might be some discrepancy and inconsistencies since this is the first time we introduce uniform formatting to Runner's html files. Error templates files (all in the "error" folder) are the only one that required some content moving/replacing so it's worth double checking if all the sentences are correct now.
Checklist