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

Support Haml 6 #1820

Merged
merged 1 commit into from Sep 27, 2022
Merged

Support Haml 6 #1820

merged 1 commit into from Sep 27, 2022

Conversation

jkowens
Copy link
Member

@jkowens jkowens commented Sep 26, 2022

Use Haml::Buffer only if it is defined. Resolves #1816.

@jkowens
Copy link
Member Author

jkowens commented Sep 26, 2022

@k0kubun I appreciate your help 🙏

I'm seeing this warning when trying to upgrade to haml 6:

Haml::TempleEngine: Option :line is invalid
/opt/hostedtoolcache/Ruby/2.6.10/x64/lib/ruby/gems/2.6.0/gems/temple-0.8.2/lib/temple/mixins/options.rb:22: warning: instance variable @option_validator_disabled not initialized

I'm also seeing our specs fail with this result:

  5) Sinatra::ContentFor Haml with content_for in Ruby passes values to the blocks
     Failure/Error: expect(render(inner, :passes_values)).to eq("<i>1</i>2")

       expected: "<i>1</i>2"
            got: "&lt;i&gt;1&lt;/i&gt;2"

It looks like Haml is escaping the output. Can we mark it safe somehow?

@k0kubun
Copy link
Contributor

k0kubun commented Sep 27, 2022

I'm seeing this warning when trying to upgrade to haml 6:

rtomayko/tilt#387 seems to address it. We'd need to get it merged.

It looks like Haml is escaping the output. Can we mark it safe somehow?

You could pass escape_html: false to the engine, or use != instead of = to embed a script without escaping it.

@jkowens
Copy link
Member Author

jkowens commented Sep 27, 2022

You could pass escape_html: false to the engine, or use != instead of = to embed a script without escaping it.

Of course! I see we do use != that for hamlit, sorry to even bother you about that 🤦‍♂️ Thank you!

Remove use of Haml::Buffer.
@froderik
Copy link
Contributor

froderik commented Dec 7, 2022

So it seems that haml 6 is not supported out of the box. I needed to explicitly configure haml to not escape html like this:

set :haml escape_html: false

in order to get yielded haml inside a layout to not be escaped. Adding it here if anyone else stumbles upon the same problem.

@dentarg
Copy link
Member

dentarg commented Dec 7, 2022

or you can use != haml ... / != yield where needed instead of allowing unescaped HTML all the time

@jkowens jkowens deleted the haml-6 branch December 24, 2022 20:39
glaszig added a commit to glaszig/amnesia that referenced this pull request Jan 28, 2023
explicitly prevent escaping of markup yielded into layout

see https://github.com/haml/haml/blob/main/CHANGELOG.md#600
see sinatra/sinatra#1820

"The default value of escape_html option became true."
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.

Sinatra::Capture is not compatible with Haml 6
4 participants