Lighthouse has a new layout.
Prefer the old one? Return to the old layout,
and switch back any time from the link at the top of each page.
This project is archived and is in readonly mode.
Capture not working when passing pre-escaped blocks (like, JSON)...
#6313
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.
Reported by tonycoco ·
January 19th, 2011 @ 12:58 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.