spec/helpers/various-utils.js
function attributesHashToString ( attributesHash, options ) {
    var reduce = options && options.reverse ? _.reduceRight : _.reduce,
        separator = options && options.multiline ? "\n" : " ",
        spacing = options && options.extrSpace || "",
        defaultQuote = options && options.preferSingleQuotes ? "'" : '"';

    return reduce( attributesHash, function ( attrString, value, key ) {
        var quote = value.indexOf( '"' ) !== -1 ? "'" :  value.indexOf( "'" ) !== -1 ? '"' : defaultQuote;
        return attrString + key + spacing + "=" + spacing + quote + value + quote + separator;
    }, "" );
}
function attributesHashToString ( attributesHash, options ) {
    var reduce = options && options.reverse ? _.reduceRight : _.reduce,
        separator = options && options.multiline ? "\n" : " ",
        spacing = options && options.extrSpace || "",
        defaultQuote = options && options.preferSingleQuotes ? "'" : '"';

    return reduce( attributesHash, function ( attrString, value, key ) {
        var quote = value.indexOf( '"' ) !== -1 ? "'" :  value.indexOf( "'" ) !== -1 ? '"' : defaultQuote;
        return attrString + key + spacing + "=" + spacing + quote + value + quote + separator;
    }, "" );
}
Transforms a hash of HTML attributes - e.g., data attributes - into a string.

The string has a trailing slash (or newline), but not a leading one. Double quotes are used by default around values,
except around JSON strings which have to be enclosed by single quotes.

The string can be used to create the HTML of a tag with the given attributes. Data attributes containing a
stringified JSON structure are fully supported (simply by using single quotes around attribute values there).

The following formatting option are available:

- The order of the attributes can be reversed.
- Attributes can be separated by newlines instead of spaces.
- Redundant whitespace can be inserted around the "=" of each assignment.
- Values can be enclosed in single quotes, rather than double quotes, where possible (skipped for values containing a
double quote character).

@param   {Object}  attributesHash
@param   {Object}  [options]
@param   {boolean} [options.reverse=false]
@param   {boolean} [options.multiline=false]
@param   {string}  [options.extraSpace=""]
@param   {boolean} [options.preferSingleQuotes=false]
@returns {string}