Skip to content

ReactionView is Cranky About Internal Rails Templates #91

@jherdman

Description

@jherdman

Greetings!

It seems like ReactionView doesn't like templates internal to Rails itself:

Error:
AscentsTest#test_user_can_delete_their_ascent_from_the_profile_page:
ActionView::Template::Error: 
HTML+ERB Compilation Errors:
============================================================

Error #1: InvalidNestingError
----------------------------------------
  File: /Users/jamesherdman/.local/share/mise/installs/ruby/4.0.1/lib/ruby/gems/4.0.0/gems/actionpack-8.1.2.1/lib/action_dispatch/middleware/templates/rescues/routing_error.html.erb
  Location: Line 9, Column 6
  Message: Block element <h2> cannot be nested inside <p> at line 9

  Source:
     6 |   <h2><%= h @exception_wrapper.message %></h2>
     7 |   <% unless @exception_wrapper.failures.empty? %>
     8 |     <p>
     9 |       <h2>Failure reasons:</h2>
              ^~~~~~~~~~~~~~~~~~~~~~~~~
    10 |       <ol>
    11 |       <% @exception_wrapper.failures.each do |route, reason| %>
    12 |         <li><code><%= route.inspect.delete('\\') %></code> failed because <%= reason.downcase %></li>

This happens when I run my Rails system tests with this configuration using ReactionView v0.3:

ReActionView.configure do |config|
  # Intercept .html.erb templates and process them with `Herb::Engine` for enhanced features
  config.intercept_erb = true # << KEY LINE IS HERE

  # Enable debug mode in development (adds debug attributes to HTML)
  config.debug_mode = Rails.env.development?

  # Validation mode (:raise, :overlay, or :none) — defaults to :raise in test, :overlay otherwise
  # config.validation_mode = :overlay

  # Add custom transform visitors to process templates before compilation
  # config.transform_visitors = [
  #   Herb::Visitor::new
  # ]
end

The workaround is simply not to have ReactionView intercept ERb.

Ought ReactionView not intercept HTML for gems?

As an aside, this template is fixed in upstream Rails rails/rails@84023df

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions