This project is archived and is in readonly mode.
Capture not working when passing pre-escaped blocks (like, JSON)...
Reported by tonycoco | January 19th, 2011 @ 12:58 AM
A quick look at the current code for reference...
# File actionpack/lib/action_view/helpers/capture_helper.rb, line 38
def capture(*args)
value = nil
buffer = with_output_buffer { value = yield(*args) }
if string = buffer.presence || value and string.is_a?(String)
ERB::Util.html_escape string
end
end
Let's say I have a block that includes JSON, like if I call #to_json on a Hash, and pass that into capture. Then, that string gets #html_escape'd TWICE. The result is impossible to deal with once you get a few layers into it. Should capture take a option[:no_escape]? Or, have an entirely separate method to call, like, #capture_without_escaping? The latter approach is what I've been doing in the ApplicationHelper of my applications. I'd write a patch file, just want to hear some thoughts on a best-practice for this.
Comments and changes to this ticket
-
tonycoco February 2nd, 2011 @ 12:59 AM
Upon further review of the newest Rails code. The capture method works as advertised. I'll continue to look at it, but I think this one can be closed out.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>