aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/CHANGELOG2
-rw-r--r--actionpack/lib/action_view/base.rb14
-rw-r--r--actionpack/test/controller/render_test.rb8
3 files changed, 18 insertions, 6 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index 1e542046fe..1c6585c27f 100644
--- a/actionpack/CHANGELOG
+++ b/actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*1.10.0* (October 16th, 2005)
+* Make string-keys locals assigns optional. Add documentation describing depreciated state [skaes@web.de]
+
* Improve line number detection for template errors [Nicholas Seckar]
* Update/clean up documentation (rdoc)
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"
diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb
index f7cf77c204..9894a70755 100644
--- a/actionpack/test/controller/render_test.rb
+++ b/actionpack/test/controller/render_test.rb
@@ -77,12 +77,16 @@ class TestController < ActionController::Base
def accessing_local_assigns_in_inline_template
name = params[:local_name]
- render :inline => "<%= 'Goodbye, ' + local_name %>", :locals => { :local_name => name }
+ render :inline => "<%= 'Goodbye, ' + local_name %>",
+ :locals => { :local_name => name }
end
def accessing_local_assigns_in_inline_template_with_string_keys
name = params[:local_name]
- render :inline => "<%= 'Goodbye, ' + local_name %>", :locals => { "local_name" => name }
+ ActionView::Base.local_assigns_support_string_keys = true
+ render :inline => "<%= 'Goodbye, ' + local_name %>",
+ :locals => { "local_name" => name }
+ ActionView::Base.local_assigns_support_string_keys = false
end
def rescue_action(e) raise end