Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jonniesweb opened this issue May 16, 2019 · 2 comments
Open

Comments

@jonniesweb
Copy link

jonniesweb commented May 16, 2019

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 😄

@SamuelCabralCruz
Copy link

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.

peteryates added a commit to DFE-Digital/get-into-teaching-app that referenced this issue Oct 14, 2021
peteryates added a commit to DFE-Digital/get-into-teaching-app that referenced this issue Oct 18, 2021
It prevents the web console from being rendered and just shows the
default uninformative error screen.

More info here: Shopify/better-html#50
peteryates added a commit to DFE-Digital/get-into-teaching-app that referenced this issue Oct 19, 2021
It prevents the web console from being rendered and just shows the
default uninformative error screen.

More info here: Shopify/better-html#50
ethax-ross pushed a commit to DFE-Digital/get-into-teaching-app that referenced this issue Oct 20, 2021
It prevents the web console from being rendered and just shows the
default uninformative error screen.

More info here: Shopify/better-html#50
@alec-c4
Copy link
Contributor

alec-c4 commented Jan 6, 2022

The same problem with lookbook gem :(

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

No branches or pull requests

4 participants
@alec-c4 @jonniesweb @SamuelCabralCruz and others