diff options
author | Rizwan Reza <rizwanreza@gmail.com> | 2010-03-28 12:04:00 +0430 |
---|---|---|
committer | Rizwan Reza <rizwanreza@gmail.com> | 2010-03-28 12:04:00 +0430 |
commit | b4c91de9462f59d6395c7c871aafa3301afdc383 (patch) | |
tree | fadcaf603a6f473e8ccd52070a1f3b4f957c34cb /actionpack/lib/action_view/template/handlers/erb.rb | |
parent | 4b4f69b9bfbd33556e23262f57cf6d944dfd9f63 (diff) | |
parent | 66d57d7ba83df52ff1e0485c89f6192c2f84c6b8 (diff) | |
download | rails-b4c91de9462f59d6395c7c871aafa3301afdc383.tar.gz rails-b4c91de9462f59d6395c7c871aafa3301afdc383.tar.bz2 rails-b4c91de9462f59d6395c7c871aafa3301afdc383.zip |
Merge remote branch 'rails/master'
Diffstat (limited to 'actionpack/lib/action_view/template/handlers/erb.rb')
-rw-r--r-- | actionpack/lib/action_view/template/handlers/erb.rb | 19 |
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 |