Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
To decrease the confusion between Drupal blocks and Twig blocks, I propose that we rename Twig's blocks. (since my attempt at renaming Drupal's blocks seems to have failed :)
How about 'codeblock' ?
Related code sample:
#1783184: [meta] Use Twig template inheritance
Comments
Comment #1
Fabianx CreditAttribution: Fabianx commentedInteresting, we should probably also throw an error Message or warning if we encounter a normal block in Twig files in Drupal.
Thoughts?
Comment #2
steveoliver CreditAttribution: steveoliver commentedI do like codeblock. It's a good option for the situation.
Comment #3
jenlamptonI also like the idea of throwing an error. Maybe a nice one that actually tells people that in Drupal we call it a 'codeblock' instead?
Comment #4
Fabianx CreditAttribution: Fabianx commentedSounds good.
I'll take care of the engine patch and then someone needs to write a "how we deviate from twig" doc.
Comment #5
jtwalters CreditAttribution: jtwalters commentedI would like to suggest the keyword
part
instead ofcodeblock
part
is a single word, quick to type, with a lower chance of making a typopart
is meaningful and has no conflict with current Drupal vocabularyComment #6
joelpittetWould prefer leaving Twig's {% block %} alone, people learning or knowing twig will most likely use it and know how to use it. Also people using Twig outside of Drupal will be a bit confused. Adding another Drupalism.
Comment #7
joelpittetWhoops, sandbox and I see it got closed #1760558: Rename 'Blocks' (Twig already uses the term 'block')
Comment #8
jenlamptonMoving issue to core queue.
Comment #8.0
jenlamptonadded link to code sample
Comment #9
star-szrThanks for moving this over Jen!
I'm with @joelpittet on this after having time to think about this and chat a bit in Prague, I like the idea of just using {% block %} and when talking about and documenting it we can call it a "twig block". Just look at all this lovely documentation we would be breaking: http://twig.sensiolabs.org/doc/tags/extends.html
Comment #10
joelpittetFeel free to re-open this if you feel strongly it will help or notice people getting confused that a twig block is not the same as a drupal block.
Triaging a bit to clean up the issue queue.
Comment #11
jenlamptonI'm not sure about this, but not willing to re-open the issue just yet. Keep in mind that most Drupal people won't know Twig, or even read the docs. The first thing they'll just open the templates and try to read/modify them. And this is the BLOCK template:
Comment #12
joelpittet@jenlampton Maybe we can help that a bit by inline comment of twig docs on the matter?
http://twig.sensiolabs.org/doc/tags/extends.html
The block is used for convenience sake, it doesn't need to be used by the themer unless they need the feature it provides.