Flowdock
convert_boolean_attributes!(html_options, bool_attrs) private

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: http://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 ) )
Show source
Register or log in to add new notes.