diff options
author | Paul Hieromnimon <paul.hieromnimon@gmail.com> | 2011-02-10 20:38:14 +0800 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-02-10 23:47:53 +0800 |
commit | f7221f5c7571da50d4d0199c0a7502cc7cd82b6e (patch) | |
tree | 9b9f3d9579a848a30b23b4c5b7c3994f10600201 /activesupport/lib | |
parent | c560c8b2ba2af2ff1942e40b8eff8287354bf7d8 (diff) | |
download | rails-f7221f5c7571da50d4d0199c0a7502cc7cd82b6e.tar.gz rails-f7221f5c7571da50d4d0199c0a7502cc7cd82b6e.tar.bz2 rails-f7221f5c7571da50d4d0199c0a7502cc7cd82b6e.zip |
Initial html_safe implemention for Array
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/core_ext/string/output_safety.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/string/output_safety.rb b/activesupport/lib/active_support/core_ext/string/output_safety.rb index c930abc003..520aa4e67d 100644 --- a/activesupport/lib/active_support/core_ext/string/output_safety.rb +++ b/activesupport/lib/active_support/core_ext/string/output_safety.rb @@ -122,3 +122,19 @@ class String ActiveSupport::SafeBuffer.new(self) end end + +class Array + + alias_method :original_join, :join + + def join(sep=$,) + sep ||= "".html_safe + str = original_join(sep) + (sep.html_safe? && html_safe?) ? str.html_safe : str + end + + def html_safe? + self.detect {|e| !e.html_safe?}.nil? + end + +end |