block.html.twig

Default theme implementation to display a block.

Available variables:

  • plugin_id: The ID of the block implementation.
  • label: The configured label of the block if visible.
  • configuration: A list of the block's configuration values.
    • label: The configured label for the block.
    • label_display: The display settings for the label.
    • module: The module that provided this block plugin.
    • cache: The cache settings.
    • Block plugin specific settings will also be stored here.
  • block - The full block entity.
    • label_hidden: The hidden block title value if the block was configured to hide the title ('label' is empty in this case).
    • module: The module that generated the block.
    • delta: An ID for the block, unique within each module.
    • region: The block region embedding the current block.
  • content: The content of this block.
  • attributes: HTML attributes for the containing element.
    • id: A valid HTML ID and guaranteed unique.
    • class: Classes that can be used to style contextually through CSS. These can be manipulated through preprocess functions. The default values can be one or more of the following:

      • block: The current template type, i.e., "theming hook".
      • block-[module]: The module generating the block. For example, the user module is responsible for handling the default user navigation block. In that case the class would be 'block-user'.
  • title_attributes: HTML attributes for the title element.
  • content_attributes: HTML attributes for the content element.
  • title_prefix: Additional output populated by modules, intended to be displayed in front of the main title tag that appears in the template.
  • title_suffix: Additional output populated by modules, intended to be displayed after the main title tag that appears in the template.

See also

template_preprocess()

template_preprocess_block()

1 theme call to block.html.twig

File

drupal/core/modules/block/templates/block.html.twig
View source
  1. {#
  2. /**
  3. * @file
  4. * Default theme implementation to display a block.
  5. *
  6. * Available variables:
  7. * - plugin_id: The ID of the block implementation.
  8. * - label: The configured label of the block if visible.
  9. * - configuration: A list of the block's configuration values.
  10. * - label: The configured label for the block.
  11. * - label_display: The display settings for the label.
  12. * - module: The module that provided this block plugin.
  13. * - cache: The cache settings.
  14. * - Block plugin specific settings will also be stored here.
  15. * - block - The full block entity.
  16. * - label_hidden: The hidden block title value if the block was
  17. * configured to hide the title ('label' is empty in this case).
  18. * - module: The module that generated the block.
  19. * - delta: An ID for the block, unique within each module.
  20. * - region: The block region embedding the current block.
  21. * - content: The content of this block.
  22. * - attributes: HTML attributes for the containing element.
  23. * - id: A valid HTML ID and guaranteed unique.
  24. * - class: Classes that can be used to style contextually through
  25. * CSS. These can be manipulated through preprocess functions. The default
  26. * values can be one or more of the following:
  27. * - block: The current template type, i.e., "theming hook".
  28. * - block-[module]: The module generating the block. For example, the user
  29. * module is responsible for handling the default user navigation block.
  30. * In that case the class would be 'block-user'.
  31. * - title_attributes: HTML attributes for the title element.
  32. * - content_attributes: HTML attributes for the content element.
  33. * - title_prefix: Additional output populated by modules, intended to be
  34. * displayed in front of the main title tag that appears in the template.
  35. * - title_suffix: Additional output populated by modules, intended to be
  36. * displayed after the main title tag that appears in the template.
  37. *
  38. * @see template_preprocess()
  39. * @see template_preprocess_block()
  40. *
  41. * @ingroup themeable
  42. */
  43. @todo Remove the div around content as per http://drupal.org/node/1972122.
  44. #}
  45. <div{{ attributes }}>
  46. {{ title_prefix }}
  47. {% if label %}
  48. <h2{{ title_attributes }}>{{ label }}</h2>
  49. {% endif %}
  50. {{ title_suffix }}
  51. <div{{ content_attributes }}>
  52. {{ content }}
  53. </div>
  54. </div>

Related topics