Skip to content

Better HTML breaks Rails error page when web-console gem is used #50

Closed

Description

@jonniesweb

Hey folks 👋

When @clayton-shopify hooked us up with better_html in https://github.com/Shopify/help/pull/7582, it introduced a bug that was fixed in https://github.com/Shopify/help/pull/7839.

What ended up happening was that when the config.allow_single_quoted_attributes = false is set and the web-console gem is installed, anytime an error occurs when developing locally causes the Rails error page to fail to render. https://github.com/Shopify/help/pull/7839 has a bit more of a description of this problem.

The one solution I discovered from the better-html README was to exclude running better-html on any of the ERB templates from the app's gems via:

BetterHtml.configure do |config|
  config.allow_single_quoted_attributes = false
  config.template_exclusion_filter = Proc.new { |filename| !filename.start_with?(Rails.root.to_s) }
end

I wasn't able to figure out a way to exclude only the web-console gem's ERB templates. The following method didn't work:

BetterHtml.configure do |config|
  config.allow_single_quoted_attributes = false
  config.template_exclusion_filter = proc do |filename|
    filename.include?('web_console')
  end
end

Let me know if there's any extra info I can provide 😄

Activity

  1. SamuelCabralCruz commented on Jul 16, 2019

    @SamuelCabralCruz

    I experienced a similar problem using mailer preview. I really think that this piece of code should go into default settings since you have no control over the quality of the gems you use and it is really cumbersome to seek for answer for a problem that you did not even create. Moreover, even if better html tells me that the gems I use do not follow the best practices, I can't do anything to change that.

  2. alec-c4 commented on Jan 6, 2022

    @alec-c4
    Contributor

    The same problem with lookbook gem :(

  3. rafaelfranca commented on Sep 18, 2025

    @rafaelfranca
    Member

    Thank you for your interest in better_html and for filing this issue.

    better_html has now been deprecated and further development is discontinued. See the deprecation notice and archived documentation in the repository, and the replacement guidance and modern tooling at:
    https://herb-tools.dev/

    The change formalizing this deprecation is documented in this commit:
    dcfeed7

    Given the project’s retired status, we’re closing all open issues. If you pursue a community fork or alternative, feel free to reference this ticket for historical context.

    Thank you again for helping improve template safety in the Rails ecosystem.

    (Automated closure)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions