Using No Markup while Twig Debug is enabled

Created on 17 July 2023, 11 months ago
Updated 15 April 2024, 2 months ago

Problem/Motivation

I wanted to use this module, but during local development I see that Twig debug statements still get produced for each field. As an example, I have a field in a Paragraph type that is printed in an HTML attribute. I normally handle this use-case exactly as your docs describe:

{{ my_field|render|striptags|trim }}

But without stripping tags and trimming, the Twig debug statement still prints in the HTML, breaking the template.

I reviewed the module and see that it's quite minimal, using a template to override the standard output. So my hopes aren't high, but I still wanted to file an issue and perhaps learn from discussion whether it's even possible to avoid the Twig debug output.

Since this won't affect prod sites that are correctly configured with Twig debug disabled, it's marked as a low priority support request.

Steps to reproduce

1. Enable Twig debug in your services.yml
2. Configure a field to be rendered with No Markup
3. Print the field in an HTML attribute in your twig template.

Proposed resolution

I don't have a proposal.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ’¬ Support request
Status

Fixed

Version

1.0

Component

Documentation

Created by

πŸ‡©πŸ‡ͺGermany rupl

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @rupl
  • Status changed to Fixed 11 months ago
  • e0ipso Can Picafort

    I do not think that the debug information can be selectively turned off at specific templates. As far as I know the core implementation will only take a global boolean to weather or not to add such comments.

    Given how much grief this produces with core's RSS views, completely breaking XML parsing, I think this is not a solvable issue.

    I am happy to revisit this if there are ideas.

  • Automatically closed - issue fixed for 2 weeks with no activity.

  • Status changed to Fixed 2 months ago
  • πŸ‡ΊπŸ‡ΈUnited States akalata

    Shouldn't the status of this issue then be something other than "fixed"?

Production build 0.69.0 2024