aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/template_handlers
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2008-06-19 22:03:27 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2008-06-19 22:21:56 -0700
commit72f93b581f1d1a7496ccebbd90578714c171c5a5 (patch)
tree0e89550d0297bba6a87c8eae507c7388d62c92e8 /actionpack/lib/action_view/template_handlers
parentc440c9b199d7474e356472616ef03f9c7e17c405 (diff)
downloadrails-72f93b581f1d1a7496ccebbd90578714c171c5a5.tar.gz
rails-72f93b581f1d1a7496ccebbd90578714c171c5a5.tar.bz2
rails-72f93b581f1d1a7496ccebbd90578714c171c5a5.zip
Check whether blocks are called from erb using a special __in_erb_template variable visible in block binding.
Diffstat (limited to 'actionpack/lib/action_view/template_handlers')
-rw-r--r--actionpack/lib/action_view/template_handlers/compilable.rb8
-rw-r--r--actionpack/lib/action_view/template_handlers/erb.rb3
2 files changed, 9 insertions, 2 deletions
diff --git a/actionpack/lib/action_view/template_handlers/compilable.rb b/actionpack/lib/action_view/template_handlers/compilable.rb
index 1aef81ba1a..783456ab53 100644
--- a/actionpack/lib/action_view/template_handlers/compilable.rb
+++ b/actionpack/lib/action_view/template_handlers/compilable.rb
@@ -106,7 +106,13 @@ module ActionView
locals_code << "#{key} = local_assigns[:#{key}]\n"
end
- "def #{render_symbol}(local_assigns)\nold_output_buffer = output_buffer;#{locals_code}#{body}\nensure\nself.output_buffer = old_output_buffer\nend"
+ <<-end_src
+ def #{render_symbol}(local_assigns)
+ old_output_buffer = output_buffer;#{locals_code}#{body}
+ ensure
+ self.output_buffer = old_output_buffer
+ end
+ end_src
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/template_handlers/erb.rb b/actionpack/lib/action_view/template_handlers/erb.rb
index 0733b3e3c2..458416b6cb 100644
--- a/actionpack/lib/action_view/template_handlers/erb.rb
+++ b/actionpack/lib/action_view/template_handlers/erb.rb
@@ -48,7 +48,8 @@ module ActionView
self.erb_trim_mode = '-'
def compile(template)
- ::ERB.new(template.source, nil, erb_trim_mode, '@output_buffer').src
+ src = ::ERB.new(template.source, nil, erb_trim_mode, '@output_buffer').src
+ "__in_erb_template=true;#{src}"
end
def cache_fragment(block, name = {}, options = nil) #:nodoc: