Skip to content
Snippets Groups Projects
Commit f211d543 authored by Rajab Natshah's avatar Rajab Natshah
Browse files

Issue #3337386: Fix Block context in theme layout and Layout Builder

parent 263bdc8f
No related branches found
No related tags found
No related merge requests found
......@@ -11,9 +11,9 @@
*/
#}
{% set tag = tag ?? 'h1' %}
{% set html_tag = tag ?? 'h1' %}
{% set utility_classes = utility_classes ?? [] %}
{% if tag %}
<{{ tag }} {{ attributes.addClass(utility_classes|join(' ')) }}>{{ content }}</{{ tag }}>
{% if html_tag %}
<{{ html_tag }} {{ attributes.addClass(utility_classes|join(' ')) }}>{{ content }}</{{ html_tag }}>
{% endif %}
......@@ -21,7 +21,7 @@
] %}
{% if items %}
<{{ tag }} class="{{ list_classes|join(' ') }}">
<{{ html_tag }} class="{{ list_classes|join(' ') }}">
{% for item in items %}
{% set item_classes = [
'list-group-item',
......@@ -30,5 +30,5 @@
] %}
<li class="{{ item_classes|join(' ') }}">{{ item.text }}</li>
{% endfor %}
</{{ tag }}>
</{{ html_tag }}>
{% endif %}
{#
/**
* @file
* Template for a Block component.
* Vartheme BS5 implementation to display a block.
*
* Available config:
* Available variables:
* - layout: String that will determine the layout of the block.
* - 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.
* - provider: The module or other provider that provided this block plugin.
* - Block plugin specific settings will also be stored here.
* - in_preview: Whether the plugin is being rendered in preview mode.
* - content: The content of this block.
* - attributes: array of HTML attributes populated by modules, intended to
* be added to the main container tag of this template.
* - id: A valid HTML ID and guaranteed unique.
* - title_attributes: Same as attributes, except applied to the main title
* tag that appears in the template.
* - content_attributes: Same as attributes, except applied to the main content
* tag that appears in the template.
* - 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.
* - html_tag: The HTML tag for the block.
* - utility_classes: An array of utility classes.
* @see template_preprocess_block()
*
* @ingroup themeable
*/
#}
{% set bundle = bundle ? 'block--' ~ bundle|clean_class : "" %}
{% set id = id ? 'block--' ~ id|replace({"_": "-"})|clean_class : "" %}
{% set classes = ['block', bundle, id] %}
{%
set classes = [
'block',
'block-' ~ configuration.provider|clean_class,
'block-' ~ plugin_id|clean_class,
layout ? 'layout--' ~ layout|clean_class,
bundle ? 'block--' ~ bundle|clean_class : "",
id ? 'block--' ~ id|replace({"_": "-"})|clean_class : "",
]
%}
{% if tag %}
<{{ tag }} class="{{ classes|join(' ') }}">
{% if html_tag %}
<{{ html_tag }} {{ attributes.addClass(classes) }}>
{% endif %}
{{ title_prefix }}
{% if label %}
{% block label %}
<h2{{ title_attributes }}>{{ label }}</h2>
{% endblock %}
<h2{{ title_attributes.addClass('block__title') }}>{{ label }}</h2>
{% endif %}
{{ title_suffix }}
{% block content %}
{{ content }}
<div{{ content_attributes.addClass('block__content') }}>
{{ content }}
</div>
{% endblock %}
{% if tag %}
</{{ tag }}>
{% if html_tag %}
</{{ html_tag }}>
{% endif %}
......@@ -18,7 +18,7 @@
id
] %}
<{{ tag }} {{ attributes.addClass(classes) }}>
<{{ html_tag }} {{ attributes.addClass(classes) }}>
{% if title_prefix %}
{{ title_prefix }}
......@@ -43,4 +43,4 @@
{{ body }}
{% endblock %}
</{{ tag }}>
</{{ html_tag }}>
......@@ -9,7 +9,7 @@
border_radius ? 'rounded-' ~ border_radius : ''
] %}
<{{ tag }} {{ attributes.addClass(classes) }}>
<{{ html_tag }} {{ attributes.addClass(classes) }}>
{% if heading %}
{% include "@atoms/heading/heading.twig" with {
attributes: heading_attributes,
......@@ -20,4 +20,4 @@
{% endif %}
<div class="rich-body mb-2">{{ content }}</div>
</{{ tag }}>
\ No newline at end of file
</{{ html_tag }}>
\ No newline at end of file
{#
/**
* @file
* Template for a block.
* Vartheme BS5 implementation to display a block.
*
* Available variables:
* - layout: String that will determine the layout of the block.
* - 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.
* - provider: The module or other provider that provided this block plugin.
* - Block plugin specific settings will also be stored here.
* - in_preview: Whether the plugin is being rendered in preview mode.
* - content: The content of this block.
* - attributes: array of HTML attributes populated by modules, intended to
* be added to the main container tag of this template.
* - id: A valid HTML ID and guaranteed unique.
* - title_attributes: Same as attributes, except applied to the main title
* tag that appears in the template.
* - content_attributes: Same as attributes, except applied to the main content
* tag that appears in the template.
* - 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 template_preprocess_block()
*
* @ingroup themeable
*/
#}
{% include '@organisms/block/block.twig' with {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment