Problem/Motivation

Currently theming in Drupal 8 still entails overriding entire templates. So for example a collection of node templates for different content types will result in a number of templates all repeating the entire contents of the node template even though each one may only be overriding a small portion of the template or adding mark-up in one area.

It has always been this way with Drupal by default, most of the solutions in the past to provide more granular targeting and flexibility have either involved modules that comprehensively change how layout is handled with Drupal (with admin configuration and functionality) or complex base themes.

Proposed resolution

Provide Twig Block mark-up in core templates that allows Twig extends to be used when overriding templates in themes, allowing for much more 'surgical' targeting of changes.

Currently a Twig Block is only used on one place (The block.html.twig template ironically) and only around the content output of this template. Adding a much more comprehensive Twig block markup in Core will allow themers to immediately reap the same advantages that are gained by Core templates that extend block.html.twig.

This issue is really for general discussion and to test the waters (I believe that the advantages adding comprehensive Twig Block mark-up make it worthwhile but there maybe some technical objections and/or other problems that would follow.

For a better idea of what I am suggesting see an experimental base theme I have started work on, there is more information in the readme.

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue category Feature because it is an improvement to the themeing
Issue priority Normal because it will not resolve errors

Comments

valthebald’s picture

Issue tags: +Barcelona2015

Evaluating this during Friday sprint

badrange’s picture

Version: 8.0.x-dev » 8.1.x-dev
Priority: Major » Normal
Issue summary: View changes
Issue tags: +markup

This looks like a great addition to the theme system. At the moment everybody are working hard on getting Drupal 8.0.0 ready, and according to the Drupal release policy the timing is not right to move forward with this feature request at the moment.

valthebald’s picture

Looks like not committable to 8.0, but will be really nice to see twig blocks in 8.1

chris_hall_hu_cheng’s picture

Yes I would agree at this point, no point in messing up the drive to finish 8 ;)

Hopefully I will have an example custom theme for reference by the time it makes sense to look at it again.

chris_hall_hu_cheng’s picture

Status: Active » Postponed

The introduction of the Stable theme in Core was a bit of a gift.

I have started a sandbox project at https://www.drupal.org/sandbox/chris_hall_hu_cheng/2646294 which is basically intended to be a copy of Stable but with Twig block markup, this can be used as an alternative base theme to the default stable.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

xjm’s picture

Very belatedly adding issue credit for the BCN triage work.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.