Support from Acquia helps fund testing for Drupal Acquia logo

Comments

foopang’s picture

Assigned: Unassigned » foopang

Let me try working on this.

foopang’s picture

Status: Active » Needs review
FileSize
2.12 KB

Please review.

star-szr’s picture

Issue tags: +Needs manual testing

Tagging.

star-szr’s picture

Status: Needs review » Needs work
Issue tags: -Needs manual testing

This is looking good, tests are passing and I did a manual test and everything works as expected.

My only concern is related to documentation. The Twig template has all the same variables available to it as the PHPTemplate one, but the Twig template file only talks about content, attributes, and attributes.class. The PHPTemplate file has better documentation, in that it also describes what classes are there by default, and it also describes the 'region' variable.

So can we bring over (and reformat) the following documentation items from the PHPTemplate file?

  • Default classes
  • Region variable

Here's an example of what the attributes documentation could look like (taken from #1898432: node.module - Convert PHPTemplate templates to Twig):

+++ b/core/modules/node/templates/node.html.twigundefined
@@ -4,57 +4,55 @@
+ * - attributes: Remaining HTML attributes for the containing element.
+ *   - attributes.class: Class information, containing:
+ *     - node: The current template type (also known as a "theming hook").
+ *     - node-[type]: The current node type. For example, if the node is a
+ *       "Article" it would result in "node-article". Note that the machine
+ *       name will often be in a short form of the human readable label.
+ *     - view-mode-[view_mode]: The View Mode of the node; for example, a teaser
+ *       would result in: "view-mode-teaser", and full: "view-mode-full".
+ *     - preview: Whether a node is in preview mode.
+ *     The following are controlled through the node publishing options.
+ *     - promoted: Appears on nodes promoted to the front page.
+ *     - sticky: Appears on nodes ordered above other non-sticky nodes in teaser
+ *       listings.
+ *     - unpublished: Appears on unpublished nodes visible only to site admins.

I think we can probably leave out is_admin, is_front, and logged_in since those are available to every template, see _template_preprocess_default_variables().

star-szr’s picture

@foopang - thanks for your work on this! Would you be able to take care of the documentation updates noted in #4? If not, please unassign and someone else can work on this.

foopang’s picture

Assigned: foopang » Unassigned

Sorry @Cottser, I have been busy I couldn't work on the documentation right now, so let unassign it for me. I will look back to this issue if no one else works on it.

star-szr’s picture

Issue tags: +Novice

No need to apologize, thanks for your work on this :)

Tagging as Novice to take care of the documentation tweaks in #4 and post a new patch and interdiff.

2ndmile’s picture

Status: Needs work » Needs review
FileSize
1.15 KB
463.8 KB

Newb alert: Review and let me know if there is anything else that needs done or anything I did incorrectly.

2ndmile’s picture

Status: Needs review » Needs work

woah.. screwed that up... please hold

2ndmile’s picture

Status: Needs work » Needs review
FileSize
981 bytes
2.45 KB

OK, this looks better (embarrassed). Please review.

2ndmile’s picture

Indentation and line wrapping for coding standards. Please review.

star-szr’s picture

Status: Needs review » Needs work

That looks much better, thanks @2ndmile! I found a couple more small tweaks related to documentation and Twig coding standards:

+++ b/core/modules/system/templates/region.html.twigundefined
@@ -0,0 +1,29 @@
+ *   - attributes.class: String of classes that can be used to style

Let's also remove "String of" and just say "Classes that can be…" per Twig coding standards (we don't describe data types in Twig template files).

+++ b/core/modules/system/templates/region.html.twigundefined
@@ -0,0 +1,29 @@
+{% if content %}
+<div class="{{ attributes.class }}"{{ attributes }}>
+  {{ content }}
+</div>
+{% endif %}

We should indent the contents of the {% if %} tag by two spaces per http://drupal.org/node/1823416#expressions.

2ndmile’s picture

Status: Needs work » Needs review
FileSize
923 bytes
2.46 KB

Changes from #12 implemented. Please review.

star-szr’s picture

Thanks!

+++ b/core/modules/system/templates/region.html.twigundefined
@@ -6,7 +6,7 @@
+ *   - attributes.class: Classes that can be used to style
  *     contextually through CSS.

Let's rewrap this now to be as long as possible within the 80 character limit per http://drupal.org/coding-standards#indenting.

thedavidmeister’s picture

Status: Needs review » Needs work
Issue tags: +Needs manual testing

+ * @see template_process()

Why do we have this? The other Twig template patches don't have this line.

Other than that and the review in #13 this looks good.

This is probably ready for manual testing, which should not be hard. If the site disappears this is broken ;)

star-szr’s picture

Issue tags: -Needs manual testing

Agreed on #15, let's remove the @see template_process().

Removing manual testing tag, I've already gone through the markup locally, we're just working on docs.

Thanks everyone!

2ndmile’s picture

Assigned: Unassigned » 2ndmile
Status: Needs work » Needs review
FileSize
396 bytes
2.43 KB

Implemented #15. Please review.

chrisjlee’s picture

joelpittet’s picture

This looks great! Couple of nitpiks:)

+++ b/core/modules/system/templates/region.html.twig
@@ -0,0 +1,28 @@
+ *   - attributes.class: Classes that can be used to style

This should probably just be - class: as the indentation denotes it's related to the above. Or don't indent (to be like the one on our Twig Coding Standards http://drupal.org/node/1823416 ])

+++ b/core/modules/system/templates/region.html.twig
@@ -0,0 +1,28 @@
+  <div class="{{ attributes.class }}"{{ attributes }}>
+    {{ content }}

Could you make that just {{ attributes }} please? We will be doing this in Bartik I believe but not in core.

star-szr’s picture

FileSize
1.01 KB
2.43 KB

Docs tweaks and changes including #19 and more. Thanks @joelpittet!

joelpittet’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Novice

I approve this message.

star-szr’s picture

Issue summary: View changes

Remove sandbox, update remaining

star-szr’s picture

Issue tags: +needs profiling

Tagging for profiling.

star-szr’s picture

Assigned: 2ndmile » star-szr

…and assigning.

star-szr’s picture

Assigned: star-szr » Unassigned
Issue tags: -needs profiling

It took me quite a while to get a solid baseline but now the numbers are coming back consistently and are looking very good.

Tested with Stark theme on a node page, with blocks placed in all 7 regions of the Stark theme. APC class loader enabled.

The first result is HEAD vs. itself - to show the the baseline run used for comparing runs is consistent.

The second result is HEAD vs. #20.

=== region-head..region-head compared (518eceb4aac68..518ed10e385b9):

ct  : 27,039|27,039|0|0.0%
wt  : 156,536|156,560|24|0.0%
cpu : 136,808|135,437|-1,371|-1.0%
mu  : 10,478,032|10,478,032|0|0.0%
pmu : 10,650,864|10,650,864|0|0.0%

http://www.lionsad.de/xhprof-kit/xhprof/xhprof_html/?run1=518eceb4aac68&...

=== region-head..region-1961868-20 compared (518eceb4aac68..518ed14bbba55):

ct  : 27,039|27,244|205|0.8%
wt  : 156,536|156,811|275|0.2%
cpu : 136,808|137,120|312|0.2%
mu  : 10,478,032|10,497,976|19,944|0.2%
pmu : 10,650,864|10,669,488|18,624|0.2%

http://www.lionsad.de/xhprof-kit/xhprof/xhprof_html/?run1=518eceb4aac68&...

alexpott’s picture

Title: Convert region.tpl.php to Twig » [READY] Convert region.tpl.php to Twig
Status: Reviewed & tested by the community » Closed (duplicate)
alexpott’s picture

Issue summary: View changes

Updated issue summary.

alexpott’s picture

Title: [READY] Convert region.tpl.php to Twig » Convert region.tpl.php to Twig
Status: Closed (duplicate) » Fixed

Committed 5b2afa0 and pushed to 8.x. Thanks!

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

Anonymous’s picture

Issue summary: View changes

Add proposed git commit message