Skip to content

Conversation

@kozy4324
Copy link
Contributor

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.

…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.
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.

1 participant