instance method convert_boolean_attributes!

Ruby on Rails 2.3.18

Since v2.2.3 Last seen in v4.2.9 Private

Available in: v2.2.3 v2.3.18 v3.0.20 v3.1.12 v3.2.22.5 v4.0.13 v4.1.16 v4.2.9

Signature

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 ) )

Parameters

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

Defined in actionpack/lib/action_view/helpers/url_helper.rb line 631 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActionView::Helpers::UrlHelper

Type at least 2 characters to search.

↑↓ navigate · open · esc close