Follow-up to #2372581: Rename 'page' render element to 'body', page.html.twig to body.html.twig

Problem/Motivation

The 'scripts_bottom' variable conditionally is populated in \Drupal\Core\Render\HtmlResponseAttachmentsProcessor::processAssetLibraries() and used in every html.html.twig template without any documentation.

Proposed resolution

document

Remaining tasks

review, commit.

User interface changes

None.

API changes

no

Beta phase evaluation

-

Reference: https://www.drupal.org/core/beta-changes
Issue category Bug because documentation missing
Issue priority Normal because changes only docs
Unfrozen changes Unfrozen because it only changes documentation of template variable
Disruption No
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

andypost’s picture

Issue tags: +Quickfix
jhodgdon’s picture

Status: Needs review » Needs work

Thanks for the issue and patch!

I think it needs a bit of work though...

+++ b/core/modules/system/templates/html.html.twig
@@ -22,6 +22,8 @@
+ * - scripts_bottom: Script tags necessary to load the JavaScript files before
+ *   clising BODY tag.

typo: clising -> closing

Also I think you want a "the" in here somewhere, and... take out one?

So this should be:

Script tags necessary to load JavaScript files before the closing BODY tag.

But really maybe BODY should not be all caps because it isn't HEAD in the rest of the docs here?

andypost’s picture

Status: Needs work » Needs review
FileSize
1.83 KB
1.83 KB

Thanx, fixed. "HEAD" uses this caps in "head" element description
Patch also fixes "the"

Status: Needs review » Needs work

The last submitted patch, 3: 2542392-scripts_bottom-3.patch, failed testing.

andypost’s picture

Status: Needs work » Needs review
FileSize
1.62 KB

fixed patch

jhodgdon’s picture

Status: Needs review » Needs work
+++ b/core/modules/system/templates/html.html.twig
@@ -20,8 +20,10 @@
+ *   closing BODY element.

So technically an element is <tag>stuff</tag>.

So there is no closing body *element*, there is a closing body *tag*.

Right?

andypost’s picture

Status: Needs work » Needs review
FileSize
1.17 KB
1.62 KB

sure, sorry, there's really difference (suppose element as a whole, tag as a part of template)

jhodgdon’s picture

Status: Needs review » Reviewed & tested by the community
Wim Leers’s picture

+++ b/core/modules/system/templates/html.html.twig
@@ -20,8 +20,10 @@
+ *   closing BODY tag.

+++ b/core/themes/classy/templates/layout/html.html.twig
@@ -20,8 +20,10 @@
+ *   closing BODY tag.

s/BODY/<body>/

jhodgdon’s picture

Sorry, putting HTML inside of PHP docs is problematic. I think this should stay as it is.

andypost’s picture

The primary reason for me to use caps is easy to grep in core

webchick’s picture

Status: Reviewed & tested by the community » Needs review

Sounds like this still needs discussion.

jhodgdon’s picture

Component: documentation » theme system

It sounds like the theming team should figure out how to refer to HTML tags in template docs, and decide how this should be done.

Putting the HTML tag like <body> directly into the PHP docs is not an option. It could be embedded in @code ... @endcode but that is normally for code blocks.

joelpittet’s picture

Assigned: Unassigned » star-szr

regex find \* .*< in *.html.twig files for reference. It seems I'd be in favour of putting in <body>

Pingging Cottser to help here.

davidhernandez’s picture

Looking through core, I don't see a lot of consistency in how this is treated, in comments at least. I see cases of <tag> and TAG and tag. This isn't just with html tags, but also with how protocols are written, for example. But for tags it seems to most often be <tag> in comments.

Looking for some template examples, we seem to have <tag> already in the templates.

https://api.drupal.org/api/drupal/core!modules!system!templates!table.ht...

I assume the api site escapes them. Where does this cause a problem?

jhodgdon’s picture

Hah! Maybe the API module does escape them. It looks like it... so let's be consistent.

andypost’s picture

FileSize
1.16 KB
1.62 KB

Filed follow-up to discuss #2546248: Use consistent style to mention HTML tags in code comments

Here's a another way

davidhernandez’s picture

+++ b/core/modules/system/templates/html.html.twig
@@ -20,8 +20,10 @@
+ * - scripts: Script tags necessary to load JavaScript files and settings
  *   in the head.

Wouldn't it be better than to use <head> here, or if not, then "in head" instead of "in the head"?

Also, with the reworking, "in" can now move to the previous line.

gtrost’s picture

Fixed patch using <head> and moving "in" to previous line.

andypost’s picture

Status: Needs review » Needs work
+++ b/core/themes/classy/templates/layout/html.html.twig
@@ -19,9 +19,9 @@
+ * - scripts: Script tags necessary to load JavaScript files and settings in ¶

trailing whitespace

gtrost’s picture

Fixed trailing white space.

andypost’s picture

Status: Needs work » Needs review

Looks good now

joelpittet’s picture

Status: Needs review » Reviewed & tested by the community

Thank you for the doc clean up.

Wim Leers’s picture

This looks like an excellent improvement :)

However, shouldn't we then be completely consistent?

+++ b/core/modules/system/templates/html.html.twig
@@ -19,9 +19,11 @@
+ * - styles: Style tags necessary to import all necessary CSS files in <head>.
+ * - scripts: Script tags necessary to load JavaScript files and settings in
...
+ * - scripts_bottom: Script tags necessary to load JavaScript files before the

s/Style tags/HTML/
s/Script tags/HTML/

(I propose not to say <style>, because most of the time we actually use <link rel="stylesheet">. That's unnecessarily detailed information for these docs. Hence just saying "HTML" is sufficient AFAICT.)

gtrost’s picture

Updated strings.

gtrost’s picture

Status: Reviewed & tested by the community » Needs review
joelpittet’s picture

Status: Needs review » Needs work

Thanks @Wim Leers and @gtrost. One small nit to finish this, I think:

  1. +++ b/core/modules/system/templates/html.html.twig
    @@ -19,9 +19,11 @@
    + * - scripts: HTML necessary to load JavaScript files and settings in
    + *   <head>.
    
    +++ b/core/themes/classy/templates/layout/html.html.twig
    @@ -19,9 +19,11 @@
    + * - scripts: HTML necessary to load JavaScript files and settings in
    + *   <head>.
    

    This doesn't need to wrap to the next line anymore.

  2. +++ b/core/modules/system/templates/html.html.twig
    @@ -19,9 +19,11 @@
    + * - scripts_bottom: HTML necessary to load JavaScript files before the
    + *   closing <body> tag.
    

    This doesn't need to change, widows like company.

star-szr’s picture

Assigned: star-szr » Unassigned

Sorry, been otherwise occupied. I can't review all the discussion right now but around where @joelpittet assigned me I agree with those things - <body> is better than BODY to me as well :)

prabhurajn654’s picture

Assigned: Unassigned » prabhurajn654
prabhurajn654’s picture

@joelpittet I have made the changes as suggested in #27. please verify.

2542392-30.patch

prabhurajn654’s picture

Assigned: prabhurajn654 » Unassigned
prabhurajn654’s picture

Status: Needs work » Needs review
joelpittet’s picture

Status: Needs review » Needs work

You are missing the second template. Also please provide an interdiff with your patch. If you haven't made one before heres the docs: @see https://www.drupal.org/documentation/git/interdiff

Also it looks like the wording changed for the styles, it should have been only a line break change between #25 and yours. One line break removal for each template.

sdstyles’s picture

Status: Needs work » Needs review
FileSize
1.82 KB
1.78 KB
Wim Leers’s picture

Status: Needs review » Reviewed & tested by the community
alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 5fcb2db and pushed to 8.0.x. Thanks!

  • alexpott committed 5fcb2db on 8.0.x
    Issue #2542392 by andypost, gtrost, sdstyles, prabhurajn654, jhodgdon,...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

prabhurajn654’s picture