diff options
author | José Valim <jose.valim@gmail.com> | 2010-03-12 12:08:23 +0100 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-03-12 12:08:23 +0100 |
commit | 4840acd485a4a6bcdd73338447af7e1340587e54 (patch) | |
tree | ff3b9fff5d9a64e475706fe2d32909ec1a3a1e47 /actionpack/lib | |
parent | 839362fa07de3f7bdf1fc1a361ff456cd02efc4e (diff) | |
download | rails-4840acd485a4a6bcdd73338447af7e1340587e54.tar.gz rails-4840acd485a4a6bcdd73338447af7e1340587e54.tar.bz2 rails-4840acd485a4a6bcdd73338447af7e1340587e54.zip |
%= works for content_tag and does not require parenthesis on method call
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_view/template/handlers/erb.rb | 53 |
1 files changed, 6 insertions, 47 deletions
diff --git a/actionpack/lib/action_view/template/handlers/erb.rb b/actionpack/lib/action_view/template/handlers/erb.rb index 2ac68d38bd..ac5902cc0e 100644 --- a/actionpack/lib/action_view/template/handlers/erb.rb +++ b/actionpack/lib/action_view/template/handlers/erb.rb @@ -3,52 +3,11 @@ require 'active_support/core_ext/string/output_safety' require 'erubis' module ActionView - class OutputBuffer - def initialize - @buffer = ActiveSupport::SafeBuffer.new - end - - def safe_concat(value) - @buffer.safe_concat(value) - end - + class OutputBuffer < ActiveSupport::SafeBuffer def <<(value) - @buffer << value.to_s - end - - def length - @buffer.length - end - - def [](*args) - @buffer[*args] - end - - def to_s - @buffer.to_s - end - - def to_str - @buffer.to_str - end - - def empty? - @buffer.empty? - end - - def html_safe? - @buffer.html_safe? - end - - if "".respond_to?(:force_encoding) - def encoding - @buffer.encoding - end - - def force_encoding(encoding) - @buffer.force_encoding(encoding) - end + super(value.to_s) end + alias :append= :<< end module Template::Handlers @@ -64,14 +23,14 @@ module ActionView def add_expr_literal(src, code) if code =~ /(do|\{)(\s*\|[^|]*\|)?\s*\Z/ - src << '@output_buffer << ' << code + src << '@output_buffer.append= ' << code else - src << '@output_buffer << (' << code << ');' + src << '@output_buffer.append= (' << code << ');' end end def add_expr_escaped(src, code) - src << '@output_buffer << ' << escaped_expr(code) << ';' + src << '@output_buffer.append= ' << escaped_expr(code) << ';' end def add_postamble(src) |