Skip to content

Respect validation_mode for external .herb templates - #116

Merged
marcoroth merged 1 commit into
mainfrom
fix-external-herb-templates
Aug 8, 2026
Merged

Respect validation_mode for external .herb templates#116
marcoroth merged 1 commit into
mainfrom
fix-external-herb-templates

Conversation

@marcoroth

Copy link
Copy Markdown
Owner

Follow up on #115.

When a gem ships a .html.herb template, it reaches ReActionView::Template::Handlers::Herb straight from the railtie. It never passes through Handlers::ERB, so nothing is in a position to rescue it.

#115 nonetheless forced validation_mode: :raise for every external template, including those, which turned what used to be a validation overlay into an uncaught exception on a template the application cannot edit:

ReActionView.config.validation_mode = :overlay
ReActionView.config.external_template_mode = :fallback

# /gems/some_gem/app/views/x.html.herb
# before: Herb::Engine::CompilationError
# after:  compiles, with the usual validation overlay

The mistake was putting the decision in Handlers::Herb, which cannot tell whether its caller will rescue. validation_mode_for is gone, and the mode is now passed in by the handler that owns the rescue.

Related #115

@marcoroth
marcoroth merged commit 5c90e0c into main Aug 8, 2026
24 checks passed
@marcoroth
marcoroth deleted the fix-external-herb-templates branch August 8, 2026 03:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant