Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[WebProfilerBundle] Add a link of the current rendered template on the twig tab of the web debug toolbar #49753

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Symfony/Bundle/WebProfilerBundle/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ CHANGELOG

* Add a "role=img" and an explicit title in the .svg file used by the web debug toolbar
to improve accessibility with screen readers for blind users
* Add a link of the current rendered template on the twig tab of the web debug toolbar
to improve user experience and make the debug easier

6.1
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,19 @@
<b>Macro Calls</b>
<span class="sf-toolbar-status">{{ collector.macrocount }}</span>
</div>
{% if collector.templates|keys %}
<div class="sf-toolbar-info-piece">
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a condition to check if there is at least a rendered template.

<b>Current rendered template</b>
{%- set template = collector.templates|keys|first -%}
{%- set file = collector.templatePaths[template]|default(false) -%}
{%- set link = file ? file|file_link(1) : false -%}
{% if link %}
<a href="{{ link }}" title="{{ file }}">{{ template }}</a>
{% else %}
{{ template }}
{% endif %}
</div>
{% endif %}
{% endset %}

{{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { link: profiler_url }) }}
Expand Down