How can I reuse a block multiple times?

SymfonyTwig

Symfony Problem Overview


How can I render a block multiple times within a view in a twig template? Currently I do have a block, let's call it something defined in an included (via render ) twig file. I then include it at the layout-twig file using the following:

{% block something %}{% endblock %}

Everything is fine, however as soon as I call this tag a second time, I get the following error message:

The block 'something ' has already been defined in "::layout.html.twig" 

Therefore: How can I render a block multiple times?

Symfony Solutions


Solution 1 - Symfony

The notation you're showing us is for defining and rendering a block. Rendering only is done this way:

{{ block('blockName') }}

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionChrisView Question on Stackoverflow
Solution 1 - Symfonygreg0ireView Answer on Stackoverflow