- Issue created by @jcandan
- πΊπΈUnited States smustgrave
@jcandan could you not use a preprocess hook to add the class to the attributes.
- Status changed to Closed: works as designed
over 1 year ago 7:51pm 1 November 2023
The current implementation of block.html.twig
does not allow additional classes from embedding templates.
Change the classes
array to accept a template config.
{#
/**
* ...
* Available config:
* - block_utility_classes: An array of utility classes for block.
*/
#}
{% set block_classes = [
'block',
'block-' ~ configuration.provider|clean_class,
'block-' ~ plugin_id|clean_class,
bundle ? 'block--type-' ~ bundle|clean_class,
view_mode ? 'block--view-mode-' ~ view_mode|clean_class,
]|merge(block_utility_classes ? block_utility_classes : []) %}
With this, a sub-theme template could expand upon the classes added to the block div.
{% include '@uswds_base/block/block.html.twig' with {
block_utility_classes: [
'my-custom-class',
],
} %}
The following example is taken from Radix. This same concept could be applied to other template files.
- [ ] Identify other template enhancement opportunities.
Closed: works as designed
3.4
Code
@jcandan could you not use a preprocess hook to add the class to the attributes.