Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 2032

Show
Ignore:
Timestamp:
08/18/05 00:52:50 (3 years ago)
Author:
stefan
Message:

proper support for {"a" => nil}

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/p2/actionpack/lib/action_view/helpers/tag_helper.rb

    r2025 r2032  
    2727        def tag_options(options) 
    2828          if options.is_a?(Hash) 
    29             options = options.stringify_keys 
    30             sorted_option_keys = options.reject { |key, value| value.nil? }.keys.sort 
    31             sorted_option_keys.inject("") { |str, key| 
    32               str << " #{key}=\"#{html_escape(options[key])}\""  
     29            cleaned_options = options.reject { |key, value| value.nil? }.stringify_keys 
     30            cleaned_options.keys.sort.inject("") { |html_str, key| 
     31              html_str << %( #{key}="#{html_escape(cleaned_options[key])}") 
    3332            } 
    3433          elsif options 
     
    3938        def tag_options(options) 
    4039          if options.is_a?(Hash) 
    41             options.inject("") { |str, (key, value)| 
    42               str << " #{key}=\"#{html_escape(value)}\"" unless value.nil? 
     40            html_str = "" 
     41            options.each { |key, value| 
     42              html_str << %( #{key}="#{html_escape(value)}") unless value.nil? 
    4343            } 
     44            html_str 
    4445          elsif options 
    4546            " " + options