aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2008-06-08 20:05:39 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2008-06-08 20:05:39 -0700
commitff5f155f8dc1d2ba363718c3e17f99719399eab5 (patch)
tree6d6e353284cc9c630697ae92f710df499d2f8197 /actionpack/lib/action_view
parentd9fb021845c0481c5119eebdc534aec427072f7d (diff)
downloadrails-ff5f155f8dc1d2ba363718c3e17f99719399eab5.tar.gz
rails-ff5f155f8dc1d2ba363718c3e17f99719399eab5.tar.bz2
rails-ff5f155f8dc1d2ba363718c3e17f99719399eab5.zip
Use output_buffer reader and writer methods exclusively instead of hitting the instance variable so others can override the methods.
Diffstat (limited to 'actionpack/lib/action_view')
-rw-r--r--actionpack/lib/action_view/helpers/capture_helper.rb6
-rw-r--r--actionpack/lib/action_view/helpers/javascript_helper.rb5
-rw-r--r--actionpack/lib/action_view/helpers/tag_helper.rb4
-rw-r--r--actionpack/lib/action_view/helpers/text_helper.rb4
-rw-r--r--actionpack/lib/action_view/template_handlers/compilable.rb2
-rw-r--r--actionpack/lib/action_view/test_case.rb5
6 files changed, 11 insertions, 15 deletions
diff --git a/actionpack/lib/action_view/helpers/capture_helper.rb b/actionpack/lib/action_view/helpers/capture_helper.rb
index 25e62f78fb..ab453fadf2 100644
--- a/actionpack/lib/action_view/helpers/capture_helper.rb
+++ b/actionpack/lib/action_view/helpers/capture_helper.rb
@@ -31,7 +31,7 @@ module ActionView
# </body></html>
#
def capture(*args, &block)
- if @output_buffer
+ if output_buffer
with_output_buffer { block.call(*args) }
else
block.call(*args)
@@ -121,10 +121,10 @@ module ActionView
private
def with_output_buffer(buf = '')
- @output_buffer, old_buffer = buf, @output_buffer
+ self.output_buffer, old_buffer = buf, output_buffer
yield
ensure
- @output_buffer = old_buffer
+ self.output_buffer = old_buffer
end
end
end
diff --git a/actionpack/lib/action_view/helpers/javascript_helper.rb b/actionpack/lib/action_view/helpers/javascript_helper.rb
index 85b205c264..7404a251e4 100644
--- a/actionpack/lib/action_view/helpers/javascript_helper.rb
+++ b/actionpack/lib/action_view/helpers/javascript_helper.rb
@@ -202,11 +202,6 @@ module ActionView
end
js_option
end
-
- private
- def block_is_within_action_view?(block)
- !@output_buffer.nil?
- end
end
JavascriptHelper = JavaScriptHelper unless const_defined? :JavascriptHelper
diff --git a/actionpack/lib/action_view/helpers/tag_helper.rb b/actionpack/lib/action_view/helpers/tag_helper.rb
index a8a5987b1f..e1abec1847 100644
--- a/actionpack/lib/action_view/helpers/tag_helper.rb
+++ b/actionpack/lib/action_view/helpers/tag_helper.rb
@@ -122,10 +122,6 @@ module ActionView
" #{attrs.sort * ' '}" unless attrs.empty?
end
end
-
- def block_is_within_action_view?(block)
- !@output_buffer.nil?
- end
end
end
end
diff --git a/actionpack/lib/action_view/helpers/text_helper.rb b/actionpack/lib/action_view/helpers/text_helper.rb
index f81f7eded6..85a3672678 100644
--- a/actionpack/lib/action_view/helpers/text_helper.rb
+++ b/actionpack/lib/action_view/helpers/text_helper.rb
@@ -26,8 +26,8 @@ module ActionView
# # will either display "Logged in!" or a login link
# %>
def concat(string)
- if @output_buffer && string
- @output_buffer << string
+ if output_buffer && string
+ output_buffer << string
else
string
end
diff --git a/actionpack/lib/action_view/template_handlers/compilable.rb b/actionpack/lib/action_view/template_handlers/compilable.rb
index 28c72172a0..1aef81ba1a 100644
--- a/actionpack/lib/action_view/template_handlers/compilable.rb
+++ b/actionpack/lib/action_view/template_handlers/compilable.rb
@@ -106,7 +106,7 @@ module ActionView
locals_code << "#{key} = local_assigns[:#{key}]\n"
end
- "def #{render_symbol}(local_assigns)\nold_output_buffer = @output_buffer;#{locals_code}#{body}\nensure\n@output_buffer = old_output_buffer\nend"
+ "def #{render_symbol}(local_assigns)\nold_output_buffer = output_buffer;#{locals_code}#{body}\nensure\nself.output_buffer = old_output_buffer\nend"
end
# Return true if the given template was compiled for a superset of the keys in local_assigns
diff --git a/actionpack/lib/action_view/test_case.rb b/actionpack/lib/action_view/test_case.rb
index 16fedd9732..1a3c93c283 100644
--- a/actionpack/lib/action_view/test_case.rb
+++ b/actionpack/lib/action_view/test_case.rb
@@ -37,6 +37,8 @@ module ActionView
if helper_class && !self.class.ancestors.include?(helper_class)
self.class.send(:include, helper_class)
end
+
+ self.output_buffer = ''
end
class TestController < ActionController::Base
@@ -48,6 +50,9 @@ module ActionView
end
end
+ protected
+ attr_accessor :output_buffer
+
private
def method_missing(selector, *args)
controller = TestController.new