查找当前视图的twig文件 [英] Find the twig file of the current view

查看:32
本文介绍了查找当前视图的twig文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我想修改当前视图中的某些内容时,我必须看到动作和控制器(例如 DefaultController:indexAction),转到动作函数(indexAction> ) 并查看该操作正在呈现的文件.

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.

是否有更快的方法来找出当前视图中呈现的文件(xxxx.html.twig)?

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

推荐答案

在主布局的某个地方,您可以添加如下内容:

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.

这篇关于查找当前视图的twig文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆