Sha256: f916b3a127fefb10a3745c7d485976d4c61cd99c1ef761820606317b9696df9b

Contents?: true

Size: 1.46 KB

Versions: 38

Compression:

Stored size: 1.46 KB

Contents

/*!
 * Jade - nodes - Attrs
 * Copyright(c) 2010 TJ Holowaychuk <tj@vision-media.ca>
 * MIT Licensed
 */

/**
 * Module dependencies.
 */

var Node = require('./node'),
    Block = require('./block');

/**
 * Initialize a `Attrs` node.
 *
 * @api public
 */

var Attrs = module.exports = function Attrs() {
  this.attrs = [];
};

/**
 * Inherit from `Node`.
 */

Attrs.prototype.__proto__ = Node.prototype;

/**
 * Set attribute `name` to `val`, keep in mind these become
 * part of a raw js object literal, so to quote a value you must
 * '"quote me"', otherwise or example 'user.name' is literal JavaScript.
 *
 * @param {String} name
 * @param {String} val
 * @param {Boolean} escaped
 * @return {Tag} for chaining
 * @api public
 */

Attrs.prototype.setAttribute = function(name, val, escaped){
  this.attrs.push({ name: name, val: val, escaped: escaped });
  return this;
};

/**
 * Remove attribute `name` when present.
 *
 * @param {String} name
 * @api public
 */

Attrs.prototype.removeAttribute = function(name){
  for (var i = 0, len = this.attrs.length; i < len; ++i) {
    if (this.attrs[i] && this.attrs[i].name == name) {
      delete this.attrs[i];
    }
  }
};

/**
 * Get attribute value by `name`.
 *
 * @param {String} name
 * @return {String}
 * @api public
 */

Attrs.prototype.getAttribute = function(name){
  for (var i = 0, len = this.attrs.length; i < len; ++i) {
    if (this.attrs[i] && this.attrs[i].name == name) {
      return this.attrs[i].val;
    }
  }
};

Version data entries

38 entries across 38 versions & 2 rubygems

Version Path
stylus-source-0.49.3 vendor/node_modules/mocha/node_modules/jade/lib/nodes/attrs.js
snowball-0.1.22 node_modules/jade/lib/nodes/attrs.js
stylus-source-0.42.2 vendor/node_modules/mocha/node_modules/jade/lib/nodes/attrs.js
stylus-source-0.42.1 vendor/node_modules/mocha/node_modules/jade/lib/nodes/attrs.js
stylus-source-0.42.0 vendor/node_modules/mocha/node_modules/jade/lib/nodes/attrs.js
stylus-source-0.41.3 vendor/node_modules/mocha/node_modules/jade/lib/nodes/attrs.js
stylus-source-0.41.2 vendor/node_modules/mocha/node_modules/jade/lib/nodes/attrs.js
stylus-source-0.41.1 vendor/node_modules/mocha/node_modules/jade/lib/nodes/attrs.js
stylus-source-0.41.0 vendor/node_modules/mocha/node_modules/jade/lib/nodes/attrs.js
stylus-source-0.40.3 vendor/node_modules/mocha/node_modules/jade/lib/nodes/attrs.js
stylus-source-0.40.2 vendor/node_modules/mocha/node_modules/jade/lib/nodes/attrs.js
stylus-source-0.40.1 vendor/node_modules/mocha/node_modules/jade/lib/nodes/attrs.js
stylus-source-0.40.0 vendor/node_modules/mocha/node_modules/jade/lib/nodes/attrs.js
stylus-source-0.39.4 vendor/node_modules/mocha/node_modules/jade/lib/nodes/attrs.js
stylus-source-0.39.3 vendor/node_modules/mocha/node_modules/jade/lib/nodes/attrs.js
stylus-source-0.39.2 vendor/node_modules/mocha/node_modules/jade/lib/nodes/attrs.js
stylus-source-0.39.1 vendor/node_modules/mocha/node_modules/jade/lib/nodes/attrs.js
stylus-source-0.39.0 vendor/node_modules/mocha/node_modules/jade/lib/nodes/attrs.js
stylus-source-0.38.0 vendor/node_modules/mocha/node_modules/jade/lib/nodes/attrs.js
stylus-source-0.37.0 vendor/node_modules/mocha/node_modules/jade/lib/nodes/attrs.js