From 96cca7db6dd2022d74fd94eb532ceacc8913b57b Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Fri, 17 Nov 2006 13:10:23 +0000 Subject: [PATCH] ActionView::Base.erb_variable accessor names the buffer variable used to render templates. Defaults to _erbout; use _buf for erubis. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5544 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/CHANGELOG | 2 +- actionpack/lib/action_controller/caching.rb | 2 +- actionpack/lib/action_view/base.rb | 3 +++ actionpack/lib/action_view/helpers/capture_helper.rb | 8 ++++---- actionpack/lib/action_view/helpers/text_helper.rb | 2 +- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index 3117fe3b1e..1b0f6e55b3 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,6 +1,6 @@ *SVN* -* Deprecate standalone components. [Jeremy Kemper] +* ActionView::Base.erb_variable accessor names the buffer variable used to render templates. Defaults to _erbout; use _buf for erubis. [Rick Olson] * assert_select_rjs :remove. [Dylan Egan] diff --git a/actionpack/lib/action_controller/caching.rb b/actionpack/lib/action_controller/caching.rb index bf1a94591e..28dc45139a 100644 --- a/actionpack/lib/action_controller/caching.rb +++ b/actionpack/lib/action_controller/caching.rb @@ -330,7 +330,7 @@ def fragment_cache_key(name) def cache_erb_fragment(block, name = {}, options = nil) unless perform_caching then block.call; return end - buffer = eval("_erbout", block.binding) + buffer = eval(ActionView::Base.erb_variable, block.binding) if cache = read_fragment(name, options) buffer.concat(cache) diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb index 1342db058d..efd2824236 100644 --- a/actionpack/lib/action_view/base.rb +++ b/actionpack/lib/action_view/base.rb @@ -183,6 +183,9 @@ class Base # that alert()s the caught exception (and then re-raises it). @@debug_rjs = false cattr_accessor :debug_rjs + + @@erb_variable = '_erbout' + cattr_accessor :erb_variable @@template_handlers = HashWithIndifferentAccess.new diff --git a/actionpack/lib/action_view/helpers/capture_helper.rb b/actionpack/lib/action_view/helpers/capture_helper.rb index 497ce093eb..1d6ad56004 100644 --- a/actionpack/lib/action_view/helpers/capture_helper.rb +++ b/actionpack/lib/action_view/helpers/capture_helper.rb @@ -56,15 +56,15 @@ module CaptureHelper def capture(*args, &block) # execute the block begin - buffer = eval("_erbout", block.binding) + buffer = eval(ActionView::Base.erb_variable, block.binding) rescue buffer = nil end if buffer.nil? - capture_block(*args, &block) + capture_block(*args, &block).to_s else - capture_erb_with_buffer(buffer, *args, &block) + capture_erb_with_buffer(buffer, *args, &block).to_s end end @@ -99,7 +99,7 @@ def capture_block(*args, &block) end def capture_erb(*args, &block) - buffer = eval("_erbout", block.binding) + buffer = eval(ActionView::Base.erb_variable, block.binding) capture_erb_with_buffer(buffer, *args, &block) end diff --git a/actionpack/lib/action_view/helpers/text_helper.rb b/actionpack/lib/action_view/helpers/text_helper.rb index c5b757d6e1..8f956133b7 100644 --- a/actionpack/lib/action_view/helpers/text_helper.rb +++ b/actionpack/lib/action_view/helpers/text_helper.rb @@ -23,7 +23,7 @@ module TextHelper # is equivalent to using: # <%= "hello" %> def concat(string, binding) - eval("_erbout", binding).concat(string) + eval(ActionView::Base.erb_variable, binding) << string end # If +text+ is longer than +length+, +text+ will be truncated to the length of -- GitLab