![Announcement icon Announcement icon](https://www.drupal.org/files/styles/grid-2-2x-square/public/announcements/drupal-evergreen-logo-280X280px%20%281%29_0.jpg?itok=PHpn6rCb)
Problem/Motivation
Bartik theme templates are incorrectly indented making readability poor. The templates need to be structured to follow best coding practises.
For eg.
<div id="messages"><div class="section clearfix">
Should be:
<div id="messages">
<div class="section clearfix">
Follow up from #1179764: Convert Bartik to HTML5
Proposed resolution
Clean up the templates. Making sure proper indentation, the right use of line breaks and blank lines etc are used so the templates are clear to read.
Documentation on Twig coding standards can be found here:
Drupal Twig coding standards : https://www.drupal.org/node/1823416
Twig coding standards: http://twig.sensiolabs.org/doc/coding_standards.html
Check out the #drupal-twig IRC channel if you need to ask questions.
Also look at other Twig template files in module files in Core for real examples.
Remaining tasks
Write a patch.
Check the patch passes with testbot.
Check the patch applies to Core.
Check nothing is broken on Bartik visually.
Add screenshots if patch is good or bad.
Review patch to check coding standards.
User interface changes
n/a
API changes
n/a
Beta phase evaluation
Issue category | Task because coding standards |
---|---|
Unfrozen changes | Unfrozen because it only changes code formatting, it doesn't change mark up |
Comment | File | Size | Author |
---|---|---|---|
#34 | drupal-clean_bartik_html_formatting-1903048-34.patch | 17.4 KB | emma.maria |
#34 | interdiff.txt | 4.02 KB | emma.maria |
#32 | interdiff.txt | 8.49 KB | lauriii |
#32 | drupal-clean_bartik_html_formatting-1903048-32.patch | 17.46 KB | lauriii |
#30 | interdiff-1903048-28-30.txt | 7.16 KB | DickJohnson |
![Acquia logo](/files/ads/acquia-issue-sponsorship.png)
Comments
Comment #1
mbrett5062 CreditAttribution: mbrett5062 commentedHave cleaned up the indentation and general formatting of Bartik's template files. This makes for better readability and as an added bonus, code folding now works as expected. Hopefully this will help speed up any future work on these templates, and aid in new user understanding of the template structure.
Comment #2
mbrett5062 CreditAttribution: mbrett5062 commentedOK that's good to go as far as I am concerned. Just need someone to review. Unassinging myself for now, to hopefully attract a reviewer.
Comment #2.0
mbrett5062 CreditAttribution: mbrett5062 commentedUpdated issue summary.
Comment #3
enhdless CreditAttribution: enhdless commentedNice patch, but the theme files have changed, so a new patch is needed.
Comment #4
emma.mariaComment #5
Anonymous (not verified) CreditAttribution: Anonymous commentedComment #6
Anonymous (not verified) CreditAttribution: Anonymous commentedHere's a new patch. Thanks to @olemedia.
Comment #7
Anonymous (not verified) CreditAttribution: Anonymous commentedComment #8
Anonymous (not verified) CreditAttribution: Anonymous commentedComment #9
emma.mariaThe indentations look great but there are a lot of inconsistent blank lines being used, especially in comment.html.twig and node.html.twig. So I still find the code hard to read.
After discussion at the Frontend table at Drupalcon Austin, we think all blank lines within Twig templates should be avoided or used if really really really needed in a consistent way.
We are waiting on final clarification from the Twig pros for the final verdict.
Comment #10
JacobSanfordRemoving 'Needs reroll' tag, looks to have been done in #6. Retesting to be sure.
Comment #11
JacobSanford6: drupal-clean_bartik_html_formatting-1903048-6.patch queued for re-testing.
Comment #12
emma.mariaComment #13
emma.mariaThe reroll was ugly as some of the templates have been reorganised and had a lot of things added to them since this issue was last worked on.
Therefore I went through the remaining templates that still needed work today and fixed the indentations in them as well as the inconsistent line spacing discussed in #9.
Comment #14
emma.mariaComment #15
sqndr CreditAttribution: sqndr commentedThis template file starts with 2 spaces. I feel like those can be removed as well.
Comment #16
GemVinny CreditAttribution: GemVinny commentedComment #17
GemVinny CreditAttribution: GemVinny commentedI have removed the 2 spaces at the start of the template. I have also cleaned up some other formatting in core/themes/bartik/templates/comment.html.twig
Comment #23
emma.mariaThe patch applies but it breaks the UI and testbot is failing.
Comment #24
emma.mariaComment #25
GemVinny CreditAttribution: GemVinny commentedComment #26
emma.mariaComment #27
DickJohnson CreditAttribution: DickJohnson commentedComment #28
DickJohnson CreditAttribution: DickJohnson commentedRerolled and fixed stuff on four different template-files. Don't think it's ready but patching changes to get it to either myself on later time or to someone else.
Comment #29
DickJohnson CreditAttribution: DickJohnson commentedComment #30
DickJohnson CreditAttribution: DickJohnson commentedNew patch around.
Comment #31
emma.maria@DickJohnson Please unassign when you are ready for an issue to be reviewed :)
Comment #32
lauriiiThere was some coding standard breaking code still
Comment #33
emma.mariaReviewing this now.
I also created a follow up issue to get all of the
<!-- /something-->
comments out of the templates. They are not needed.#2395825: Remove closing tag comments in template files.
Comment #34
emma.mariaI noticed a few more indentation errors, mostly in page.html.twig.
See interdiff and new patch.
We need at least one more set of fresh eyes on this to be able to set it to RTBC.
Comment #37
joelpittetThis looks like a nice cleanup. Thank you @emma.maria et al!
Comment #40
joelpittetBack to RTBC. testbot hiccup.
Comment #41
LewisNymanAdded beta evaluation
Comment #43
DickJohnson CreditAttribution: DickJohnson commentedPatch applies and works for me so queueing and back to RTBC.
Comment #45
webchickAhhh, that's nice on the eyes. :)
Committed and pushed to 8.0.x. Thanks!
Comment #47
emma.mariaThanks @webchick :)