Your Location is: Home > Symfony

Is it possible to extend block in macro in twig

From: Korea View: 4327 user3083231 

Question

I want to extend block inside a macros. So basically inject my JS,CSS sources for this macros. I am trying to get this approach working, but somehow it is not working as expected.

{% macro autocomplete(value, name, placeholder, class, hidden_class) %}
    {% block javascripts_footer %}
        {{ encore_entry_script_tags('autocomplete') }}
    {% endblock %}
    <input type="hidden" name="{{ name }}" class="{{ hidden_class }}" value="{{ value }}">
    <input type="text"
        class="input-autocomplete form-control form-control-sm {{ class }}"
        data-holder="{{ class }}_holder"
        data-ignore="1"
        value="{{ placeholder }}"
    >

{% endmacro %}

Best answer