-
-
Notifications
You must be signed in to change notification settings - Fork 501
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
Problem with escaped fields_for / simple_fields_for when used in a trailblazer cell #670
Comments
Just for reference, the haml issue was resolved by haml/haml@297c0d9 |
This is impossible to debug for me without looking into trailblazer which I don't know. Could you help me with a minimal runnable example showing the undesired behaviour. |
Hey, I created a mini project here : https://github.com/sebabouche/trb-slim-nested-form-issue. I could explain you how things are working with TRB by chat? |
And I pushed it on heroku here : https://trb-slim.herokuapp.com |
Ok thx, I will take a look |
@sebabouche This is not at all a minimal demo. I have limited time to debug such things which are not directly related to slim but more to framework integration. Also the haml fix is totally unrelated since it removes some haml monkey patch which slim doesn't have. Did you already ask @apotonick about it? Is there something weird going on concerning the capturing? |
Does it work correctly if you use == instead of = in the form? (This is not a fix, just to see if it would work) |
Thanks @minad. The problem is that slim HTML-escapes a string even though it's turned off in cells-slim: https://github.com/trailblazer/cells-slim/blob/cce8e43924ec1d2c32f51dc426e20061e5723102/lib/cell/slim.rb#L13 |
@apotonick Ok, however I don't think this is a good idea. Is it not possible to just mark the strings html_safe and let slim do the work? |
@apotonick You should probably also use the Slim::RailsTemplate |
@minad , I'll shrink the mini project to refom + cell + slim. It seems that it's not related to trailblazer. |
No way, Cells is completely decoupled from Rails, that's why it's so fast and popular. 😬 We don't use By having that strong interface, we are about 10x faster than Rails (and less code). @sebabouche You don't even need Reform, just the |
Ok I understand. Can you take a look at the code that slim generates since you say that it escapes despite being told not to do so? Just access the See here: |
@output_buffer = []; _temple_html_pretty1 = /<code|<pre|<textarea/; @output_buffer << ("<h3 class=\"page-header\">\n What do you want to talk about ?\n</h3>".freeze);
;
; _slim_controls1 = simple_form_for contract, html: {class: css_class} do |f|; _slim_controls2 = '';
;
; _slim_controls2 << ((::Temple::Utils.indent_dynamic((f.error_notification), true, "\n", _temple_html_pretty1)).to_s);
;
; _slim_controls2 << ((::Temple::Utils.indent_dynamic((f.input :name, placeholder: "Name", label: false, readonly: contract.readonly?(:name)), false, "\n", _temple_html_pretty1)).to_s);
; _slim_controls2 << ((::Temple::Utils.indent_dynamic((f.input :description, placeholder: "Description", label: false), false, "\n", _temple_html_pretty1)).to_s);
; _slim_controls2 << ((::Temple::Utils.indent_dynamic((f.input :file, as: :file), false, "\n", _temple_html_pretty1)).to_s);
; _slim_controls2 << ("<br />\n<div class=\"panel panel-default\">\n <div class=\"panel-heading\">\n <h3>\n Do you know any authors?\n </h3>\n </div>\n <div class=\"panel-body\">".freeze);
;
;
;
;
;
; if signed_in?;
; _slim_controls2 << ((::Temple::Utils.indent_dynamic((f.input :is_author, as: :boolean, label: "I'm the author"), true, "\n ", _temple_html_pretty1)).to_s);
;
; end; _slim_controls3 = f.simple_fields_for :users do |ff|; _slim_controls4 = '';
; if @operation.instance_of? Thing::Create;
; _slim_controls4 << ((::Temple::Utils.indent_dynamic((ff.input :email), false, "\n ", _temple_html_pretty1)).to_s);
; else;
; _slim_controls4 << ((::Temple::Utils.indent_dynamic((ff.input :email, readonly: ff.object.readonly?), false, "\n ", _temple_html_pretty1)).to_s);
; if ff.object.removeable?;
; _slim_controls4 << ((::Temple::Utils.indent_dynamic((ff.input :remove, as: :boolean, input_html: {checked: false}), false, "\n ", _temple_html_pretty1)).to_s);
;
; end; end; _slim_controls4; end; _slim_controls2 << ((::Temple::Utils.indent_dynamic((_slim_controls3), false, "\n ", _temple_html_pretty1)).to_s); _slim_controls2 << ("\n </div>\n</div>".freeze); _slim_controls2 << ((::Temple::Utils.indent_dynamic((f.submit), true, "\n", _temple_html_pretty1)).to_s);
; _slim_controls2; end; @output_buffer << (::Temple::Utils.indent_dynamic((_slim_controls1), false, "\n", _temple_html_pretty1)); @output_buffer = @output_buffer.join("".freeze) |
@minad @apotonick is this bug already fixed? |
I have the same problem with |
Same problem over here |
Same problem for me using Slim + Example:
And in my partial, I had @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. |
This is still an issue. In Rails (though I suppose this could be generalized), I figured a workaround which involves putting all the stuff under = form_for @object do |f|
...
= CGI::unescape_html(self.(:fields_for_something, f).to_str) Note: I have to call |
Same problem here.
|
I got this error message when using slim, what's the problem? Anyone help? Thanks |
That looks like you're using ERB? @tarvos21 |
@apotonick, oh yes, it's in nanoc, a site generator, with slim, but I don't know what's the problem here. |
I have the same problem. I found workaround, which works for me. = raw(f.fields_for(:files) { |files_f| files_f.file_field :file }) |
In my case == f.simple_fields_for(:children) { |form| cell(AnotherCell, form.object, f: form).to_s.html_safe }.to_s |
Thanks opted that too, though I didn't need to == f.simple_form_for(@model) {|form| cell(FormContents, form).() } |
When transposing the trailblazer demo app Gemgem (which is using haml) to slim, we are facing a problem with slim escaping
fields_for
orsimple_fields_for
.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
The text was updated successfully, but these errors were encountered: