diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2008-07-15 18:42:22 -0700 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2008-07-15 18:42:22 -0700 |
commit | ecc054352512cac8c0895c78c5f3d043046dcfec (patch) | |
tree | f912cb8d90909eb829a7f7aec9f0d021bcad2790 /actionpack/lib | |
parent | fbef982e4b906b879240a35a1ecff447007da6b2 (diff) | |
download | rails-ecc054352512cac8c0895c78c5f3d043046dcfec.tar.gz rails-ecc054352512cac8c0895c78c5f3d043046dcfec.tar.bz2 rails-ecc054352512cac8c0895c78c5f3d043046dcfec.zip |
JavaScriptGenerator should only sets output_buffer for the duration of the update block
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_view/helpers/capture_helper.rb | 17 | ||||
-rw-r--r-- | actionpack/lib/action_view/helpers/prototype_helper.rb | 5 |
2 files changed, 12 insertions, 10 deletions
diff --git a/actionpack/lib/action_view/helpers/capture_helper.rb b/actionpack/lib/action_view/helpers/capture_helper.rb index 720e2da8cc..e86ca27f31 100644 --- a/actionpack/lib/action_view/helpers/capture_helper.rb +++ b/actionpack/lib/action_view/helpers/capture_helper.rb @@ -122,14 +122,15 @@ module ActionView nil end - private - def with_output_buffer(buf = '') - self.output_buffer, old_buffer = buf, output_buffer - yield - output_buffer - ensure - self.output_buffer = old_buffer - end + # Use an alternate output buffer for the duration of the block. + # Defaults to a new empty string. + def with_output_buffer(buf = '') #:nodoc: + self.output_buffer, old_buffer = buf, output_buffer + yield + output_buffer + ensure + self.output_buffer = old_buffer + end end end end diff --git a/actionpack/lib/action_view/helpers/prototype_helper.rb b/actionpack/lib/action_view/helpers/prototype_helper.rb index edb43844a4..8c8c22dd4a 100644 --- a/actionpack/lib/action_view/helpers/prototype_helper.rb +++ b/actionpack/lib/action_view/helpers/prototype_helper.rb @@ -580,9 +580,10 @@ module ActionView class JavaScriptGenerator #:nodoc: def initialize(context, &block) #:nodoc: @context, @lines = context, [] - @context.output_buffer = @lines if @context include_helpers_from_context - @context.instance_exec(self, &block) + @context.with_output_buffer(@lines) do + @context.instance_exec(self, &block) + end end private |