Example:
dashboard.html.twig:
<% extends layout.twig.html %>
<% include ('filter.html.twig') %>
<% block javascripts %>
< %endblock >
filter.html.twig:
filter form definition and html
filter form definition and html
filter form definition and html
<% block javascripts %>
javascript for use in filter form
javascript for use in filter form
<% endblock %>
I want the filter's javascript to be set in the layout, because that way it is loaded AFTER the JQuery.
But the Javascript is rendered right after the filter form, so getting $ is undefined
.
So whatI want is the Javascript defined in filter.html.twig
to override the block in layout.html.twig
, same as extends
.
Thanks!
Included templates can't alter the blocks of their includer.
The "best" way I found is using the deferred block extension. It delays the render of a block. If you follow the advanced example in my link you can see how you could solve it