Problem
The blocks sub-module is not picking up the main _content_format for rendering block content.
Steps to reproduce
Atm the code is hard-code to markup-rendering:
foreach ($blocks as $block) {
if ($render = $block->getPlugin()->build()) {
$customElement = CustomElement::createFromRenderArray($render)
->toRenderArray();
$output[$region][$block->id()] = $this->getrenderer()
->renderRoot($customElement);
}
if ($cacheableDependency) {
$cacheableDependency->addCacheableDependency($block->getPlugin());
$cacheableDependency->addCacheableDependency($block);
}
}Proposed resolution
- read main request and apply desired content-format from there
- make use of \Drupal\custom_elements\CustomElementsBlockRenderHelperTrait::convertBlockRenderArray() in case no main custom element is provided in the render array.
- extend test coverage to ensure both markup and json rendering works
Issue fork lupus_decoupled-3561237
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #4
fagoaccidentally merged the first PR too early (mixed it up with another issue!). Thus reverted that and opened another MR.
The second MR is now ready.
Comment #6
fagoManually tested, has test coverage, all green - merged.