aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers
diff options
context:
space:
mode:
authorrizwanreza <rizwanreza@gmail.com>2009-08-08 22:21:25 +0100
committerPratik Naik <pratiknaik@gmail.com>2009-08-08 22:21:32 +0100
commit5786395760f1e1906c878df4023cac3741e66e87 (patch)
treea85a8c2dd8c5a3803103c52d1b04d7f0e6801025 /actionpack/lib/action_view/helpers
parent761283ffdb5750f8a38e2ed67891d2b2b9152d7f (diff)
downloadrails-5786395760f1e1906c878df4023cac3741e66e87.tar.gz
rails-5786395760f1e1906c878df4023cac3741e66e87.tar.bz2
rails-5786395760f1e1906c878df4023cac3741e66e87.zip
Allow content_tag options to take an array [#1741 state:resolved] [rizwanreza, Nick Quaranto]
Example: content_tag('p', "limelight", :class => ["song", "play"]) # => <p class="song play">limelight</p> Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
Diffstat (limited to 'actionpack/lib/action_view/helpers')
-rw-r--r--actionpack/lib/action_view/helpers/tag_helper.rb16
1 files changed, 7 insertions, 9 deletions
diff --git a/actionpack/lib/action_view/helpers/tag_helper.rb b/actionpack/lib/action_view/helpers/tag_helper.rb
index eea797abb5..ff5a2134ff 100644
--- a/actionpack/lib/action_view/helpers/tag_helper.rb
+++ b/actionpack/lib/action_view/helpers/tag_helper.rb
@@ -134,16 +134,14 @@ module ActionView
def tag_options(options, escape = true)
unless options.blank?
attrs = []
- if escape
- options.each_pair do |key, value|
- if BOOLEAN_ATTRIBUTES.include?(key)
- attrs << %(#{key}="#{key}") if value
- else
- attrs << %(#{key}="#{escape_once(value)}") if !value.nil?
- end
+ options.each_pair do |key, value|
+ if BOOLEAN_ATTRIBUTES.include?(key)
+ attrs << %(#{key}="#{key}") if value
+ elsif !value.nil?
+ final_value = value.is_a?(Array) ? value.join(" ") : value
+ final_value = escape_once(final_value) if escape
+ attrs << %(#{key}="#{final_value}")
end
- else
- attrs = options.map { |key, value| %(#{key}="#{value}") }
end
" #{attrs.sort * ' '}" unless attrs.empty?
end