Skip to content

Engine: Add support for disabling debug spans in ERBBlockNode via comments#977

Merged
marcoroth merged 4 commits intomarcoroth:mainfrom
kozy4324:add-support-for-disabling-debug-spans
Mar 6, 2026
Merged

Engine: Add support for disabling debug spans in ERBBlockNode via comments#977
marcoroth merged 4 commits intomarcoroth:mainfrom
kozy4324:add-support-for-disabling-debug-spans

Conversation

@kozy4324
Copy link
Contributor

@kozy4324 kozy4324 commented Dec 14, 2025

This PR is an attempt to address the issue discussed in #605.

When rendering ERB output inside content_for, it is not possible to know at template-analysis time whether the content will eventually be used in a context where emitting debug spans is invalid (for example, inside a <title> element).

Because of this, the current behavior can result in broken HTML depending on how and where the content_for content is consumed.

To address this, this PR introduces a way for ERB template authors to explicitly opt out of debug spans at the ERB block level by adding a # herb:debug disable comment to the block.
When such a comment is present, DebugVisitor skips wrapping ERB expressions within that ERBBlockNode.

This doesn’t fully solve the question of a good syntax for disabling debug spans on individual <%= expressions, but it provides a practical workaround for the original issue without relying on fragile inline comment placement.

Regarding documentation: I did not add any documentation changes in this PR. The herb repository itself does not currently document debug mode, and it seems more appropriate for this behavior to be documented on the reactionview side (for example, in https://reactionview.dev/guides/debug-mode ).

If this approach doesn’t feel right, please feel free to say so — I’m very open to feedback or alternative directions.

Resolves #605

…ments

DebugVisitor now skips wrapping ERB expressions when the enclosing
ERBBlockNode includes a `# herb:debug disable` comment.
This allows ERB template authors to explicitly opt out of debug
spans for specific ERBBlockNode.
Copy link
Owner

@marcoroth marcoroth left a comment

Choose a reason for hiding this comment

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

Thank you so much @kozy4324! 🙏🏼

I just merged in main and resolved the conflicts 🙌🏼

@marcoroth marcoroth changed the title Engine: Add support for disabling debug spans in ERBBlockNode via comments Engine: Add support for disabling debug spans in ERBBlockNode via comments Mar 6, 2026
@marcoroth marcoroth merged commit 132c740 into marcoroth:main Mar 6, 2026
24 checks passed
@marcoroth marcoroth added this to the v1.0.0 milestone Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Engine: Do not output Herb debug information for <title> elements that use content_for

2 participants