-
Notifications
You must be signed in to change notification settings - Fork 6
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
Nested model-backed form content (fields_for) gets html escaped #2
Comments
in response to: trailblazer#2
in response to: trailblazer#2
Hi perhaps submit a PR for this fix? I am running to this as well |
I never submitted a PR for this because my work-around uses |
Any ideas for alternatives to this workaround? It fixes the rendering of the fields_for but causes some strange rendering issues for the rest of my cells. |
Use Erbse master and it should all work! |
I'm using erbse master and still getting the same problem. After installing the latest commit and adding html_safe to the capture method on my end, it's solved the problem for me. def capture(*args)
yield(*args).html_safe
end |
@PeteTyldesley have you tried something like this? In your cell:
and in your view call Maybe not ideal, but at least you don't have to use the shotgun approach of always returning html_safe strings from |
@lukeasrodgers Thanks, that is a much better approach. You are totally right, there's no need for such a brute force method as the one I mentioned! |
As discussed on Gitter, I have this problem where nested
fields_for
are escaped when rendered. I've been doing some research and conclude that it happens<<
method is executedTL;DR For a temporary workaround apply
$ sed -i -e '25s:):).html_safe:' $(bundle show cells-erb)/lib/cell/erb/template.rb
to cells-erb-0.0.6.When the form is a model object the
concat
method in activesupport-4.2.4/lib/active_support/core_ext/string/output_safety.rb#184 is used:self
is aActiveSupport::SafeBuffer
value
is aString
When the form has no model it uses cells-4.0.2/lib/cell/view_model.rb#163
self
is aCell::ViewModel::OutputBuffer
string
is aString
A solution to this problem is to apply
.html_safe
to the output buffer incells-erb-0.0.6/lib/cell/erb/template.r
:Replace line with
I do not understand the code well enough to know if that is the right solution but it does solve the problem for my use-case.
The text was updated successfully, but these errors were encountered: