aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack')
-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
-rw-r--r--actionpack/test/template/template_test.rb10
-rw-r--r--actionpack/test/template/url_helper_test.rb2
7 files changed, 26 insertions, 25 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
diff --git a/actionpack/test/template/template_test.rb b/actionpack/test/template/template_test.rb
index 5c655d5b69..81fb34b80f 100644
--- a/actionpack/test/template/template_test.rb
+++ b/actionpack/test/template/template_test.rb
@@ -11,11 +11,9 @@ class TestERBTemplate < ActiveSupport::TestCase
end
class Context
- attr_accessor :_template
-
def initialize
@output_buffer = "original"
- @_virtual_path = nil
+ @virtual_path = nil
end
def hello
@@ -24,7 +22,7 @@ class TestERBTemplate < ActiveSupport::TestCase
def partial
ActionView::Template.new(
- "<%= @_template.virtual_path %>",
+ "<%= @virtual_path %>",
"partial",
ERBHandler,
:virtual_path => "partial"
@@ -86,9 +84,9 @@ class TestERBTemplate < ActiveSupport::TestCase
end
def test_virtual_path
- @template = new_template("<%= @_template.virtual_path %>" \
+ @template = new_template("<%= @virtual_path %>" \
"<%= partial.render(self, {}) %>" \
- "<%= @_template.virtual_path %>")
+ "<%= @virtual_path %>")
assert_equal "hellopartialhello", render
end
diff --git a/actionpack/test/template/url_helper_test.rb b/actionpack/test/template/url_helper_test.rb
index fc330f7a73..8d0f0124c2 100644
--- a/actionpack/test/template/url_helper_test.rb
+++ b/actionpack/test/template/url_helper_test.rb
@@ -9,7 +9,7 @@ class UrlHelperTest < ActiveSupport::TestCase
# or request.
#
# In those cases, we'll set up a simple mock
- attr_accessor :controller, :request, :_template
+ attr_accessor :controller, :request
routes = ActionDispatch::Routing::RouteSet.new
routes.draw do