Problem/Motivation
It has been difficult for themers to determine which theme function or template produced the markup they wish to modify, and usually involves searching the Drupal codebase for instances of classes or other such identifiers found in the resulting markup.
Proposed resolution
Output the full path and name of the template file used for each block of markup in HTML comment tags before and after the markup when Debug mode is enabled (Need reference to Twig/theme debug mode, and how to enable it):
<!-- START /sites/all/themes/mytheme/templates/node/node--1.html.twig -->
<!-- END /sites/all/themes/mytheme/templates/node/node--1.html.twig -->
Remaining tasks
- Have Twig theme engine produce these comments without the need to change any .html.twig template files.
User interface changes
None visible in output, only HTML comments in markup.
API changes
None.
Original idea by Fabianx
See Fabian's comment (#25) in #1808254: Standardize and simplify the attribute syntax in Twig template files
Comments
Comment #1
Fabianx CreditAttribution: Fabianx commentedComment #2
Fabianx CreditAttribution: Fabianx commentedHopefully getting to this after the big core rebase :-).
Comment #3
Fabianx CreditAttribution: Fabianx commentedFixed.
Commited to front-end:
http://drupalcode.org/sandbox/pixelmord/1750250.git/commit/19ad5b3d0d427...
I also added:
So you can also see "direct" suggestions.
TODO in follow-up: Create GUI for activating / de-activating this.
Comment #4
Fabianx CreditAttribution: Fabianx commentedNow also works with suggestions:
Comment #5
Fabianx CreditAttribution: Fabianx commentedRe-open to add format like:
Comment #6
Fabianx CreditAttribution: Fabianx commentedfixed
http://drupalcode.org/sandbox/pixelmord/1750250.git/commit/6e1c158d8304e...
@todo but should not do the processing for the suggestions if debug_verbose is off:
Comment #7
Fabianx CreditAttribution: Fabianx commentedIt's in Core: http://drupal.org/node/1906506#comment-7082814
:-)
Comment #8
ollu CreditAttribution: ollu commentedFor thoose like me that are looking for what to do to implement this feature ...
settings.php
$conf['theme_debug'] = TRUE;
at the bottom of the file.
drush clear cache all
Comment #9
joos CreditAttribution: joos commentedFrom: https://www.drupal.org/project/drupal/issues/2839709
Add the twig.config related lines to development.services.yml, under parameters: key: