From 5786395760f1e1906c878df4023cac3741e66e87 Mon Sep 17 00:00:00 2001 From: rizwanreza Date: Sat, 8 Aug 2009 22:21:25 +0100 Subject: Allow content_tag options to take an array [#1741 state:resolved] [rizwanreza, Nick Quaranto] Example: content_tag('p', "limelight", :class => ["song", "play"]) # =>

limelight

Signed-off-by: Pratik Naik --- actionpack/lib/action_view/helpers/tag_helper.rb | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'actionpack/lib/action_view/helpers/tag_helper.rb') 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 -- cgit v1.2.3