Reputation: 157
I need include a twig file with a block, but this file will be added in differents places. The file is this:
HTML CODE BLABLA
{% block javascript %}
<script>
Code associated with the html
</script>
{% endblock %}
With include, is inserted all but not respect order block. Also I can load template with "use" but I havent access to the vars :S
{% include 'file.html.twig' %} No respect block
{% use 'file.html.twig' %} cant access vars
How can I do it ?. (Sorry for my english)
Upvotes: 6
Views: 3992
Reputation: 1161
Have you tried the embed tag?
The embed tag combines the behaviour of include and extends. It allows you to include another template's contents, just like include does. But it also allows you to override any block defined inside the included template, like when extending a template.
Upvotes: 1