aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/template/handlers/erb.rb
diff options
context:
space:
mode:
authorwycats <wycats@gmail.com>2010-03-26 15:10:24 -0700
committerwycats <wycats@gmail.com>2010-03-26 15:10:24 -0700
commit197904341f2b2f21d69c653cede3aec124e86720 (patch)
tree83f1234e238016126860a929594db22e1862d783 /actionpack/lib/action_view/template/handlers/erb.rb
parent76d2c455c0607b4cd5f238cadef8f933a18567fb (diff)
parentb3a0aed028835ce4551c4a76742744a40a71b0be (diff)
downloadrails-197904341f2b2f21d69c653cede3aec124e86720.tar.gz
rails-197904341f2b2f21d69c653cede3aec124e86720.tar.bz2
rails-197904341f2b2f21d69c653cede3aec124e86720.zip
Merge branch 'master' into docrails
Diffstat (limited to 'actionpack/lib/action_view/template/handlers/erb.rb')
-rw-r--r--actionpack/lib/action_view/template/handlers/erb.rb19
1 files changed, 18 insertions, 1 deletions
diff --git a/actionpack/lib/action_view/template/handlers/erb.rb b/actionpack/lib/action_view/template/handlers/erb.rb
index ac5902cc0e..705c2bf82e 100644
--- a/actionpack/lib/action_view/template/handlers/erb.rb
+++ b/actionpack/lib/action_view/template/handlers/erb.rb
@@ -8,6 +8,13 @@ module ActionView
super(value.to_s)
end
alias :append= :<<
+
+ def append_if_string=(value)
+ if value.is_a?(String) && !value.is_a?(NonConcattingString)
+ ActiveSupport::Deprecation.warn("<% %> style block helpers are deprecated. Please use <%= %>", caller)
+ self << value
+ end
+ end
end
module Template::Handlers
@@ -21,14 +28,24 @@ module ActionView
src << "@output_buffer.safe_concat('" << escape_text(text) << "');"
end
+ BLOCK_EXPR = /(do|\{)(\s*\|[^|]*\|)?\s*\Z/
+
def add_expr_literal(src, code)
- if code =~ /(do|\{)(\s*\|[^|]*\|)?\s*\Z/
+ if code =~ BLOCK_EXPR
src << '@output_buffer.append= ' << code
else
src << '@output_buffer.append= (' << code << ');'
end
end
+ def add_stmt(src, code)
+ if code =~ BLOCK_EXPR
+ src << '@output_buffer.append_if_string= ' << code
+ else
+ super
+ end
+ end
+
def add_expr_escaped(src, code)
src << '@output_buffer.append= ' << escaped_expr(code) << ';'
end