Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I reuse a block multiple times?

Tags:

twig

symfony

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?

like image 987
Chris Avatar asked Mar 08 '12 10:03

Chris


1 Answers

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

{{ block('blockName') }} 
like image 138
greg0ire Avatar answered Oct 03 '22 01:10

greg0ire