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
Issue category | Feature because it is an improvement to the themeing |
---|---|
Issue priority | Normal because it will not resolve errors |
Comments
Comment #1
valthebaldEvaluating this during Friday sprint
Comment #2
badrange CreditAttribution: badrange at Wunder commentedThis 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.
Comment #3
valthebaldLooks like not committable to 8.0, but will be really nice to see twig blocks in 8.1
Comment #4
chris_hall_hu_cheng CreditAttribution: chris_hall_hu_cheng as a volunteer commentedYes 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.
Comment #5
chris_hall_hu_cheng CreditAttribution: chris_hall_hu_cheng as a volunteer commentedThe 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.
Comment #7
xjmVery belatedly adding issue credit for the BCN triage work.
Comment #12
joelpittetPostponed isn't the right status for this, moving back to active. It was really postponed on the release.
Comment #17
esolitosI am surprised this hasn't taken any interest, seems to me a great feature to have, so may times i've simply copied over the twig from classy/stable jsut to add the twig blocks and then extend it where needed.
Is there another open issue a part from this on the mater maybe which I haven't seen?