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


Fabianx’s picture

Interesting, we should probably also throw an error Message or warning if we encounter a normal block in Twig files in Drupal.


steveoliver’s picture

I do like codeblock. It's a good option for the situation.

jenlampton’s picture

I 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?

Fabianx’s picture

Issue tags: +Needs Documentation

Sounds good.

I'll take care of the engine patch and then someone needs to write a "how we deviate from twig" doc.

jtwalters’s picture

I would like to suggest the keyword part instead of codeblock

  • part is a single word, quick to type, with a lower chance of making a typo
  • part is meaningful and has no conflict with current Drupal vocabulary
joelpittet’s picture

Would 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.

joelpittet’s picture

jenlampton’s picture

Project: » Drupal core
Version: » 8.x-dev
Component: Twig engine (twig_engine branch) » theme system
Issue tags: -Needs Documentation +Twig

Moving issue to core queue.

jenlampton’s picture

Issue summary: View changes

added link to code sample

Cottser’s picture

Issue summary: View changes

Thanks 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:

joelpittet’s picture

Assigned: Fabianx » Unassigned
Status: Active » Closed (won't fix)

Feel 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.

jenlampton’s picture

I'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:

<div{{ attributes }}>
  {{ title_prefix }}
  {% if label %}
    <h2{{ title_attributes }}>{{ label }}</h2>
  {% endif %}
  {{ title_suffix }}

  <div{{ content_attributes }}>
    {% block content %}
      {{ content }}
    {% endblock %}
joelpittet’s picture

@jenlampton Maybe we can help that a bit by inline comment of twig docs on the matter?

The block is used for convenience sake, it doesn't need to be used by the themer unless they need the feature it provides.