Chris
Chris

Reputation: 8109

How can I reuse a block multiple times?

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?

Upvotes: 78

Views: 28905

Answers (1)

greg0ire
greg0ire

Reputation: 23255

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

{{ block('blockName') }}

Upvotes: 181

Related Questions