private Method

UrlHelper.convert_boolean_attributes!(html_options, bool_attrs)

Processes the html_options hash, converting the boolean attributes from true/false form into the form required by HTML/XHTML. (An attribute is considered to be boolean if its name is listed in the given bool_attrs array.)

More specifically, for each boolean attribute in html_options given as:

"attr" => bool_value

if the associated bool_value evaluates to true, it is replaced with the attribute’s name; otherwise the attribute is removed from the html_options hash. (See the XHTML 1.0 spec, section 4.5 "Attribute Minimization" for more: www.w3.org/TR/xhtml1/#h-4.5)

Returns the updated html_options hash, which is also modified in place.

Example:

convert_boolean_attributes!( html_options,
                             %w( checked disabled readonly ) )

Source Code

# File action_view/helpers/url_helper.rb, line 514
def convert_boolean_attributes!(html_options, bool_attrs)
  bool_attrs.each { |x| html_options[x] = x if html_options.delete(x) }
  html_options
end
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.