Find the twig file of the current view

2019-07-05 14:10发布

问题:

When I want to modify something in the current view I have to see the action and the controller( DefaultController:indexAction for example ) , go to the action function ( indexAction ) and see what file that action is rendering.

Is there a faster way to find out which is the file (xxxx.html.twig) that is getting rendered in the current view ?

回答1:

Somewhere in your main layout, you can add something like this :

{% if app.environment == 'dev' %}
    {% block templateName %}{% endblock %}
{% endif %}

And where you want to see your layout's path, you put :

{% block templateName %}{{ _self.templateName }}{% endBlock %}

This will display the template name everywhere you want when you're in development enviornment.



标签: symfony twig