diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2008-07-15 10:42:50 -0700 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2008-07-15 10:42:50 -0700 |
commit | 3c282f3a0a7c1d5ab91241674251794ead5fa41d (patch) | |
tree | b778441511f7aae27fd56d6a36facea30ee7e0a2 /actionpack/lib/action_view/helpers | |
parent | 4d76bad387036d96a955eae7c260a9633e915d11 (diff) | |
download | rails-3c282f3a0a7c1d5ab91241674251794ead5fa41d.tar.gz rails-3c282f3a0a7c1d5ab91241674251794ead5fa41d.tar.bz2 rails-3c282f3a0a7c1d5ab91241674251794ead5fa41d.zip |
Ruby 1.9 compat: only eval with block.binding in 1.9, uses more memory than eval with block
Diffstat (limited to 'actionpack/lib/action_view/helpers')
-rw-r--r-- | actionpack/lib/action_view/helpers/tag_helper.rb | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/actionpack/lib/action_view/helpers/tag_helper.rb b/actionpack/lib/action_view/helpers/tag_helper.rb index e9b6dd6e43..5a296da247 100644 --- a/actionpack/lib/action_view/helpers/tag_helper.rb +++ b/actionpack/lib/action_view/helpers/tag_helper.rb @@ -110,12 +110,18 @@ module ActionView 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) |