Permalink
Browse files

Ruby 1.9 compat: only eval with block.binding in 1.9, uses more memor…

…y than eval with block
  • Loading branch information...
jeremy committed Jul 15, 2008
1 parent 4d76bad commit 3c282f3a0a7c1d5ab91241674251794ead5fa41d
Showing with 12 additions and 6 deletions.
  1. +12 −6 actionpack/lib/action_view/helpers/tag_helper.rb
@@ -110,12 +110,18 @@ def escape_once(html)
private
BLOCK_CALLED_FROM_ERB = 'defined? __in_erb_template'
- # Check whether we're called from an erb template.
- # We'd return a string in any other case, but erb <%= ... %>
- # can't take an <% end %> later on, so we have to use <% ... %>
- # and implicitly concat.
- def block_called_from_erb?(block)
- block && eval(BLOCK_CALLED_FROM_ERB, block.binding)
+ if RUBY_VERSION < '1.9.0'
+ # Check whether we're called from an erb template.
+ # We'd return a string in any other case, but erb <%= ... %>
+ # can't take an <% end %> later on, so we have to use <% ... %>
+ # and implicitly concat.
+ def block_called_from_erb?(block)
+ block && eval(BLOCK_CALLED_FROM_ERB, block)
+ end
+ else
+ def block_called_from_erb?(block)
+ block && eval(BLOCK_CALLED_FROM_ERB, block.binding)
+ end
end
def content_tag_string(name, content, options, escape = true)

0 comments on commit 3c282f3

Please sign in to comment.