slim: Problem with escaped fields_for / simple_fields_for when used in a trailblazer cell

When transposing the trailblazer demo app Gemgem (which is using haml) to slim, we are facing a problem with slim escaping fields_for or simple_fields_for. capture d ecran 2015-12-07 a 21 01 16 This seems to come from ActionView escaping everything and everywhere.

Haml has solved it with gem "haml", github: "haml/haml", ref: "7c7c169" which should be merged soon.

That doesn’t make %haml cooler than slim 😉 Would be great if we could solve this for slim too in a future version!

The slim trailblazer demo app (reproducing the problem) can be seen here: https://github.com/sebabouche/traildemo/tree/1bd1c96e760c8811ef14ad50d784f3351774e667

About this issue

  • Original URL
  • State: open
  • Created 9 years ago
  • Reactions: 1
  • Comments: 26 (7 by maintainers)

Most upvoted comments

Same problem for me using Slim + fields_for + Spree CMS 3.1.1. Tried making a partial in Slim and it escapes the content. Is there a workaround at all? I hate to have to use ERB. Tried == form.fields_for, but no dice. I’m not using cells at all, so I’m wondering if I should create another issue. It’s just a simple form_for with fields_for

Example:

= render partial: 'line_item', collection: order_form.object.line_items, locals: { order_form: order_form }

And in my partial, I had order_form.fields_for :line_items, line_item do |item_form|, everything after that got escaped. My whole project is written in Slim except for this partial that uses fields_for. I ended up just coding it in ERB (yuck), which is really unacceptable.

@tjjjwxzq - I appreciate you showing an example, but I wasn’t able to get this to work properly in my project, not sure what I was doing wrong.

In my case fields_for didn’t work but this did:

== f.simple_fields_for(:children) { |form| cell(AnotherCell, form.object, f: form).to_s.html_safe }.to_s

@minad @apotonick is this bug already fixed?