diff options
author | Aman Gupta <aman@tmm1.net> | 2013-03-04 20:36:25 -0800 |
---|---|---|
committer | Aman Gupta <aman@tmm1.net> | 2013-03-04 20:37:54 -0800 |
commit | b1c4469f9cb3800adb99d062c6748154bc0e1b16 (patch) | |
tree | 25a6f36ca73c3ac97e912bf845e00f73ea08a5a0 /actionpack | |
parent | 40936da37222f3a669505b8e428062c4118ca30e (diff) | |
download | rails-b1c4469f9cb3800adb99d062c6748154bc0e1b16.tar.gz rails-b1c4469f9cb3800adb99d062c6748154bc0e1b16.tar.bz2 rails-b1c4469f9cb3800adb99d062c6748154bc0e1b16.zip |
Use ActionView::OutputBuffer#safe_append= from templates
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_view/buffers.rb | 6 | ||||
-rw-r--r-- | actionpack/lib/action_view/template/handlers/erb.rb | 6 |
2 files changed, 9 insertions, 3 deletions
diff --git a/actionpack/lib/action_view/buffers.rb b/actionpack/lib/action_view/buffers.rb index 2372d3c433..361a0dccbe 100644 --- a/actionpack/lib/action_view/buffers.rb +++ b/actionpack/lib/action_view/buffers.rb @@ -8,9 +8,15 @@ module ActionView end def <<(value) + return self if value.nil? super(value.to_s) end alias :append= :<< + + def safe_concat(value) + return self if value.nil? + super(value.to_s) + end alias :safe_append= :safe_concat end diff --git a/actionpack/lib/action_view/template/handlers/erb.rb b/actionpack/lib/action_view/template/handlers/erb.rb index 5aaafc15c1..52534655eb 100644 --- a/actionpack/lib/action_view/template/handlers/erb.rb +++ b/actionpack/lib/action_view/template/handlers/erb.rb @@ -11,7 +11,7 @@ module ActionView def add_text(src, text) return if text.empty? - src << "@output_buffer.safe_concat('" << escape_text(text) << "');" + src << "@output_buffer.safe_append='" << escape_text(text) << "';" end # Erubis toggles <%= and <%== behavior when escaping is enabled. @@ -31,7 +31,7 @@ module ActionView if code =~ BLOCK_EXPR src << '@output_buffer.append= ' << code else - src << '@output_buffer.append= (' << code << ');' + src << '@output_buffer.append=(' << code << ');' end end @@ -39,7 +39,7 @@ module ActionView if code =~ BLOCK_EXPR src << "@output_buffer.safe_append= " << code else - src << "@output_buffer.safe_concat((" << code << ").to_s);" + src << "@output_buffer.safe_append=(" << code << ");" end end |