Active
Project:
Drupal core
Version:
main
Component:
other
Priority:
Normal
Category:
Plan
Assigned:
Unassigned
Reporter:
Created:
8 Oct 2017 at 14:35 UTC
Updated:
3 Jan 2026 at 04:43 UTC
Jump to comment: Most recent
In Drupal 8, twig debug mode can be enabled using the documented procedure.
This can break some aspects of the site, which is unfortunate because it is rather confusing to developers if a recommended debug tool changes the behaviour of the site being debugged.
Taking the example of RSS views we could:
RssResponseTwigDebugFilter implements EventSubscriberInterface that fixes the feed by moving the comments after the <xml> tag
Comments
Comment #2
adamps commentedComment #3
adamps commentedComment #4
dawehnerI'm wondering whether we could fix all those issues by somehow just add twig theme suggestions when we actually render HTML.
Not sure how this would be possible, but trying can't hurt :)
Comment #5
dcam commentedI had this issue come up with the Views TimelineJS module this week. The module's Views plugin outputs a JSON object containing the timeline's data to drupalSettings. When Twig debugging is enabled it outputs the debugging info for the data fields into that JSON object, breaking parts of the timeline. A link to that issue is listed here under the "Referenced By" section above.
Comment #12
dalemoore commentedIgnore my response please. (Wish I could delete this comment...)
Comment #16
jwilson3Comment #17
jwilson3Comment #19
jwilson3Comment #20
nick hope commented@jwilson3 The issue you added was already 2nd in the list.
Comment #21
jwilson3Whoops! Thanks for catching that and the cleanup
Comment #23
tgoeg commentedChiming in here and adding another case where this causes problems: #3363487: newline on glossify-link.html.twig causes extra space.
I also had this in a custom theme when checking whether a field is empty (which it was, but not when the debug code inserts newlines).
This does not only cause problems in non-HTML output as the RSS output might imply.
All of my problems got fixed by the following patch and I think it does more good than bad, so I think it could be included in core.
Current firefox and chromium add newlines to comments in developer tools anyway, so this does not really cause any disadvantage for developers, I think, and it really fixes problems on a lot of places (in my case).
Applies against Drupal 10.1
Comment #24
tgoeg commentedComment #25
tgaugesI suggest adding #3563677: Twig debug can influence rendering visually due to whitespace between tags as a child to this issue. It implements a fix similar to the one suggested in #23, implements a new test, and updates existing tests.
I could not find a clear duplicate issue, but please update the issue if you do.
Comment #26
jwilson3