better-html icon indicating copy to clipboard operation
better-html copied to clipboard

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

Open jonniesweb opened this issue 5 years ago • 2 comments

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 😄

jonniesweb avatar May 16 '19 19:05 jonniesweb

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.

SamuelCabralCruz avatar Jul 16 '19 00:07 SamuelCabralCruz

The same problem with lookbook gem :(

alec-c4 avatar Jan 06 '22 10:01 alec-c4