Top

mixin Node-Attributes

Extends Node with utility attribute getters.

Details:
See:

Methods

attr(name) → {String}

Gets the value for the given attribute name.

Parameters
  • name {String} :

    attribute name

Returns
  • {String} :

    value

Example
//<movie tags="sci-fi, horror, adventures" />
$movie.attr('tags')
// => "sci-fi, horror, adventures"

get(name, [opt]) → {String}

This method is like attr but will use an attribute parser if there is one predefined for the given attribute name.

Parameters
  • name {String} :

    attribute name

  • [opt] {Object} :

    options to pass into attribute parser

Returns
  • {String} :

    value

has(name) → {Boolean}

Checks if node has or not an attribute with the given name

Parameters
  • name {String} :

    attribute name

Returns
  • {Boolean}

dsv(name, [delimiter]) → {Array.<String>}

Gets Delimiter Separated Value An utility method converts given attribute value into dsv array

Parameters
  • name {String} :

    the name of the attribute

  • [delimiter] {String} :

    delimiter string

Returns
  • {Array.<String>}
Example
//<movie tags="sci-fi, horror, adventures">
$movie.dsv('tags',',')
// => ["sci-fi", "horror", "adventures"]