Class: AttributeBuilder

CMS.AttributeBuilder(attribute_stringopt)

new AttributeBuilder(attribute_stringopt)

Parameters:
Name Type Attributes Default Description
attribute_string string | null <optional>
null
Source:

Members

attributes :Object.<string, {values: Array.<string>, quote_style: (string|null)}>

Type:
  • Object.<string, {values: Array.<string>, quote_style: (string|null)}>
Source:

Methods

addAttribute(key, value, quote_styleopt)

Add an attribute key/value pair to the list of attributes

Used to standardize various shorthand declarations to their usable format, meant to be called once-per-pair

For example, the following shorthands are supported: '.red' value can be passed with no key for a class name '#thing' value can be passed with no key for an ID

Parameters:
Name Type Attributes Default Description
key string | null
value string
quote_style string | null <optional>
null
Source:

asString()

Flatten a processed list of attributes (key, values, quote_style), to a flat string to be sent directly to the browser

Source:
Returns:

string

getValue(key) → {string}

Get the value for the requested key

Parameters:
Name Type Description
key string
Source:
Returns:
Type
string

loadString(attribute_string)

Process all extended attributes as a string into their individual parts

Will return a list of every key with its values and any quotations required note, each value will be an array of values, generally used for classes, but available for everything (except IDs).

Parameters:
Name Type Description
attribute_string string | null

String of attributes (usually from MD) to load

Source: