Skip to content
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

Capture not working when passing pre-escaped blocks (like, JSON)... #818

Closed
lighthouse-import opened this issue May 16, 2011 · 1 comment

Comments

@lighthouse-import
Copy link

Imported from Lighthouse. Original ticket at: http://rails.lighthouseapp.com/projects/8994/tickets/6313
Created by tonycoco - 2011-02-22 17:42:04 UTC

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.

@lighthouse-import
Copy link
Author

Imported from Lighthouse.
Comment by tonycoco - 2011-02-02 00:59:41 UTC

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant