trailblazer / cells

View components for Ruby and Rails.
https://trailblazer.to/2.1/docs/cells.html
3.06k stars 236 forks source link

Slim v5 breaks cells #502

Closed AlfonsoUceda closed 1 year ago

AlfonsoUceda commented 1 year ago

Hello everyone, with the recent release of slim gem v5 I receive the following error:

undefined method `safe_concat' for []:Cell::ViewModel::OutputBuffer

If I patch this class lib/cell/view_model.rb:138 with alias_method :safe_concat, :<< I don't see any error like this but using render inside a slim cell file it renders using a string, so you see the HTML printed in the application instead of rendering the slim file

apotonick commented 1 year ago

Hi @AlfonsoUceda,

HTML printed in the application instead of rendering the slim file

how do you mean this?

AlfonsoUceda commented 1 year ago

Hey @apotonick

Imaging having HTML printed in the browser as text, that you can see the HTML tags (raw HTML) so the it is not interpreted as HTML.

apotonick commented 1 year ago

That sounds like a problem with html_escape... I currently don't have resources for fixing this (we're using ERB everywhere), maybe you want to investigate?

AlfonsoUceda commented 1 year ago

Will do @apotonick ;)

apotonick commented 1 year ago

My guess is you need to do safe_html! in safe_concat. It's not beautiful but neither is Rails' view layer! :beers:

AlfonsoUceda commented 1 year ago

I've seen that this change in temple gem is the problem: https://github.com/judofyr/temple/pull/135, reverting that change makes it work, but not sure if there is a way to fix it or wait until rails 7.1 is released because of the changes in Rails described in that PR and the implications in cell gems.

Could it be a problem for ERB too? because cells-erb uses erbse that uses temple gem.

AlfonsoUceda commented 1 year ago

@apotonick what do you think about this?

apotonick commented 1 year ago

@AlfonsoUceda I see a comment that they believe it works with older Rails versions - aren't you saying that it doesn't work for you? Is Slim using Temple under the hood?

AlfonsoUceda commented 1 year ago

Going to close this issue because I've opened one in cells-slim https://github.com/trailblazer/cells-slim/issues/27