aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2011-05-01 11:14:38 +0200
committerJosé Valim <jose.valim@gmail.com>2011-05-01 13:40:12 +0200
commitbebaccdf4a3a17f2ead349cca891032e245655ff (patch)
treeb0c1e7f663862251b58248a520478a99ed503635 /actionpack/lib/action_view
parentd08f65118cc328de5493a68db33a155487f5fceb (diff)
downloadrails-bebaccdf4a3a17f2ead349cca891032e245655ff.tar.gz
rails-bebaccdf4a3a17f2ead349cca891032e245655ff.tar.bz2
rails-bebaccdf4a3a17f2ead349cca891032e245655ff.zip
Remove dependency from _template.
Diffstat (limited to 'actionpack/lib/action_view')
-rw-r--r--actionpack/lib/action_view/base.rb3
-rw-r--r--actionpack/lib/action_view/helpers/form_helper.rb2
-rw-r--r--actionpack/lib/action_view/helpers/translation_helper.rb4
-rw-r--r--actionpack/lib/action_view/template.rb14
-rw-r--r--actionpack/lib/action_view/test_case.rb16
5 files changed, 21 insertions, 18 deletions
diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb
index c1dbbe1613..0866e808e6 100644
--- a/actionpack/lib/action_view/base.rb
+++ b/actionpack/lib/action_view/base.rb
@@ -159,7 +159,7 @@ module ActionView #:nodoc:
end
end
- attr_accessor :_template, :_view_flow
+ attr_accessor :_view_flow
attr_internal :request, :controller, :config, :assigns, :lookup_context
# TODO Consider removing those setters once we have the renderer in place.
@@ -191,6 +191,7 @@ module ActionView #:nodoc:
@_virtual_path = nil
@_view_flow = OutputFlow.new
@output_buffer = nil
+ @virtual_path = nil
if @_controller = controller
@_request = controller.request if controller.respond_to?(:request)
diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb
index 68db17c254..b6bb90a3ce 100644
--- a/actionpack/lib/action_view/helpers/form_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_helper.rb
@@ -1172,7 +1172,7 @@ module ActionView
class FormBuilder
# The methods which wrap a form helper call.
class_attribute :field_helpers
- self.field_helpers = (FormHelper.instance_method_names - ['form_for'])
+ self.field_helpers = FormHelper.instance_method_names - %w(form_for convert_to_model)
attr_accessor :object_name, :object, :options
diff --git a/actionpack/lib/action_view/helpers/translation_helper.rb b/actionpack/lib/action_view/helpers/translation_helper.rb
index 26ebae6546..ec9bdd5320 100644
--- a/actionpack/lib/action_view/helpers/translation_helper.rb
+++ b/actionpack/lib/action_view/helpers/translation_helper.rb
@@ -63,8 +63,8 @@ module ActionView
private
def scope_key_by_partial(key)
if key.to_s.first == "."
- if (path = @_template && @_template.virtual_path)
- path.gsub(%r{/_?}, ".") + key.to_s
+ if @virtual_path
+ @virtual_path.gsub(%r{/_?}, ".") + key.to_s
else
raise "Cannot use t(#{key.inspect}) shortcut because path is not available"
end
diff --git a/actionpack/lib/action_view/template.rb b/actionpack/lib/action_view/template.rb
index 6dfc4f68ae..98ecd15aa0 100644
--- a/actionpack/lib/action_view/template.rb
+++ b/actionpack/lib/action_view/template.rb
@@ -139,15 +139,12 @@ module ActionView
# we use a bang in this instrumentation because you don't want to
# consume this in production. This is only slow if it's being listened to.
def render(view, locals, buffer=nil, &block)
- old_template, view._template = view._template, self
ActiveSupport::Notifications.instrument("!render_template.action_view", :virtual_path => @virtual_path) do
compile!(view)
view.send(method_name, locals, buffer, &block)
end
rescue Exception => e
handle_render_error(view, e)
- ensure
- view._template = old_template
end
def mime_type
@@ -174,12 +171,7 @@ module ActionView
end
def inspect
- @inspect ||=
- if defined?(Rails.root)
- identifier.sub("#{Rails.root}/", '')
- else
- identifier
- end
+ @inspect ||= defined?(Rails.root) ? identifier.sub("#{Rails.root}/", '') : identifier
end
protected
@@ -264,9 +256,9 @@ module ActionView
# encoding of the code
source = <<-end_src
def #{method_name}(local_assigns, output_buffer)
- _old_output_buffer = @output_buffer;#{locals_code};#{code}
+ _old_virtual_path, @virtual_path = @virtual_path, #{@virtual_path.inspect};_old_output_buffer = @output_buffer;#{locals_code};#{code}
ensure
- @output_buffer = _old_output_buffer
+ @virtual_path, @output_buffer = _old_virtual_path, _old_output_buffer
end
end_src
diff --git a/actionpack/lib/action_view/test_case.rb b/actionpack/lib/action_view/test_case.rb
index 5c74bf843a..14e032790d 100644
--- a/actionpack/lib/action_view/test_case.rb
+++ b/actionpack/lib/action_view/test_case.rb
@@ -147,9 +147,19 @@ module ActionView
module Locals
attr_accessor :locals
- def _render_partial(options)
- locals[options[:partial]] = options[:locals]
- super(options)
+ def render(options = {}, local_assigns = {})
+ case options
+ when Hash
+ if block_given?
+ locals[options[:layout]] = options[:locals]
+ elsif options.key?(:partial)
+ locals[options[:partial]] = options[:locals]
+ end
+ else
+ locals[options] = local_assigns
+ end
+
+ super
end
end