Drupal - Place a block inside a twig template

Download and enable Twig tweak module:

Twig Tweak module provides a Twig extension with some useful functions and filters that can improve developer experience.

And then on your twig template put:

<dd>{{ drupal_view('view_name', 'block_1') }}</dd>
<dd>{{ drupal_block('block_id') }}</dd>

Themers Little Helper

Some of the Filters and functions, backported from TFD7 theme engine and other things that can help a themer getting stuff done without to much hassle :)

{{ drupal_block(block_delta) }}

Bamboo Twig

The Bamboo Twig module provides some Twig extensions with some useful functions and filters aimed to improve the development experience.

Bamboo Twig has a lot of advantages and brings a lot of new features to the Twig landscape of Drupal 8. It boosts performance by using lazy loading, improves the code quality with automated workflow. It also includes automated unit and kernel tests to ensure stability.

{# Render the `system_powered_by_block` block #}
{{ bamboo_render_block('system_powered_by_block') }}

Tags:

Theming

8