diff options
author | Nicholas Seckar <nseckar@gmail.com> | 2005-10-17 15:51:07 +0000 |
---|---|---|
committer | Nicholas Seckar <nseckar@gmail.com> | 2005-10-17 15:51:07 +0000 |
commit | cb8bb70aa7fa100ea04b8de39fa5fcb99271758d (patch) | |
tree | c4acea3d5defbad90f8bb0840694d9faf6167612 /actionpack/lib/action_view | |
parent | 2c64b9d1270b0ef468f13152c9acd68e0bb49fd6 (diff) | |
download | rails-cb8bb70aa7fa100ea04b8de39fa5fcb99271758d.tar.gz rails-cb8bb70aa7fa100ea04b8de39fa5fcb99271758d.tar.bz2 rails-cb8bb70aa7fa100ea04b8de39fa5fcb99271758d.zip |
Make string-keys locals assigns optional
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2665 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_view')
-rw-r--r-- | actionpack/lib/action_view/base.rb | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb index 4c065a0ae5..ecf7553e8d 100644 --- a/actionpack/lib/action_view/base.rb +++ b/actionpack/lib/action_view/base.rb @@ -133,6 +133,12 @@ module ActionView #:nodoc: @@cache_template_loading = false cattr_accessor :cache_template_loading + # Specify whether local_assigns should be able to use string keys. + # Defaults to +true+. String keys are depreciated and will be removed + # shortly. + @@local_assigns_support_string_keys = true + cattr_accessor :local_assigns_support_string_keys + @@template_handlers = {} module CompiledTemplates #:nodoc: @@ -258,6 +264,8 @@ module ActionView #:nodoc: method_name = @@method_names[file_path || template] evaluate_assigns + local_assigns = local_assigns.symbolize_keys if @@local_assigns_support_string_keys + send(method_name, local_assigns) do |*name| instance_variable_get "@content_for_#{name.first || 'layout'}" end @@ -365,10 +373,8 @@ module ActionView #:nodoc: @@template_args[render_symbol] = locals_keys.inject({}) { |h, k| h[k] = true; h } locals_code = "" - unless locals_keys.empty? - locals_code << locals_keys.inject("local_assigns = local_assigns.symbolize_keys\n") do |code, key| - code << "#{key} = local_assigns[:#{key}] if local_assigns.has_key?(:#{key})\n" - end + locals_keys.each do |key| + locals_code << "#{key} = local_assigns[:#{key}] if local_assigns.has_key?(:#{key})\n" end "def #{render_symbol}(local_assigns)\n#{locals_code}#{body}\nend" |