public function RenderBlock::render_block in Twig Blocks 8
Provides function to programmatically rendering a block.
Parameters
string $block_id The machine id of the block to render.:
File
- src/
Twig/ RenderBlock.php, line 40 - Contains \Drupal\twig_blocks\Twig\RenderBlock.
Class
- RenderBlock
- Adds extension to render a block.
Namespace
Drupal\twig_blocks\TwigCode
public function render_block($block_id) {
$block = \Drupal\block\Entity\Block::load($block_id);
$markup = \Drupal::entityTypeManager()
->getViewBuilder('block')
->view($block);
return [
'#markup' => drupal_render($markup),
];
}