symfony - Twig template parent() caused double parent block -
i have base.html.twig
template.html.twig
, dashboard.html.twig
. dashboard extends template extends base.
base:
{% block javascripts %} <script src="1.js"></script> {% endblock %}
template:
{% block javascripts %} {{ parent() }} <script src="2.js"></script> {% endblock %}
dashboard:
{% block javascripts %} {{ parent() }} <script src="3.js"></script> {% endblock %}
this templating setup resulted in redundant script tags doubled this
<script src="1.js"></script> <script src="2.js"></script> <script src="3.js"></script> <script src="1.js"></script> <script src="2.js"></script> <script src="3.js"></script>
am missing something? why happening?
edit1:
base.html.twig:
extends nothing
template.html.twig:
{% extends 'base.html.twig' %}
default/dashboard.html.twig:
{% extends '::template.html.twig' %}
in opinion {% extends "file" %}
bad.
the fix :
template :
{% extends "base_path" %} {% block javascripts %} {{ parent() }} <script src="2.js"></script> {% endblock %}
dashboard :
{% extends "template_path" %} {% block javascripts %} {{ parent() }} <script src="3.js"></script> {% endblock %}
Comments
Post a Comment