Extracts attributes from template tags as an array of objects

@example of output
[
{
key: 'src',
value: 'partial.html'
},
{
key: 'title',
value: 'Some title'
}
]

@param {String} tag - tag to replace
@returns {Array.<Object>}
420083
function getAttributes(tag) {
        let running = true;
        const attributes = [];
        const regexp = /(\S+)=["']?((?:.(?!["']?\s+(?:\S+)=|[>"']))+.)["']?/g;

        while (running) {
            const match = regexp.exec(tag);

            if (match) {
                attributes.push({
                    key: match[1],
                    value: match[2]
                })
            } else {
                running = false;
            }
        }

        return attributes;
    }
602689
function(tagname, attributes){
						// TODO: improve so VNode does not hold attributes as javascript (use Attributes object)
						template.appendChild(new VNode(ontext(template, tagname, {virtual: false}).pop(), attributesToJavascript(template, attributes)));
						template.push();
					}
465221
def parse_tag(template, l_del, r_del):
    """"""
    global _CURRENT_LINE
    global _LAST_TAG_LINE

    tag_types = {
        '!': 'comment',
        '#': 'section',
        '^': 'inverted section',
        '/': 'end',
        '>': 'partial',
        '=': 'set delimiter?',
        '{': 'no escape?',
        '&': 'no escape'
    }

    # Get the tag
    try:
        tag, template = template.split(r_del, 1)
    except ValueError:
        raise ChevronError('unclosed tag '
                           'at line {0}'.format(_CURRENT_LINE))

    # Find the type meaning of the first character
    tag_type = tag_types.get(tag[0], 'variable')

    # If the type is not a variable
    if tag_type != 'variable':
        # Then that first character is not needed
        tag = tag[1:]

    # If we might be a set delimiter tag
    if tag_type == 'set delimiter?':
        # Double check to make sure we are
        if tag.endswith('='):
            tag_type = 'set delimiter'
            # Remove the equal sign
            tag = tag[:-1]

        # Otherwise we should complain
        else:
            raise ChevronError('unclosed set delimiter tag\n'
                               'at line {0}'.format(_CURRENT_LINE))

    # If we might be a no html escape tag
    elif tag_type == 'no escape?':
        # And we have a third curly brace
        # (And are using curly braces as delimiters)
        if l_del == '{{' and r_del == '}}' and template.startswith('}'):
            # Then we are a no html escape tag
            template = template[1:]
            tag_type = 'no escape'

    # Strip the whitespace off the key and return
    return ((tag_type, tag.strip()), template)
1217202
def getElementsByAttr(self, attrName, attrValue):
        '''
            
        '''
        elements = []
        for child in self.children:
            if child.getAttribute(attrName) == attrValue:
                elements.append(child)
            elements += child.getElementsByAttr(attrName, attrValue)
        return TagCollection(elements)
520823
function htmlToComponent(str, tags, opts) {
  var keys = objectKeys(tags);
  var props = opts.props || {};
  var preserveAttributes = opts.preserveAttributes || [];
  var tagAttributes = [];
  var reactTags={};
  var reactKeys=[];
  var key;
  for(var i = 0; i<keys.length; i++) {
    key = "AB"+Math.random().toString(36).substring(2);
    if(typeof tags[keys[i]] !== "function") {
      if(typeof tags[keys[i]].slice !== "function") continue;
      tagAttributes = tags[keys[i]].slice(0,-1);
      reactTags[key] = tags[keys[i]].slice(-1)[0];
    }
    else
      reactTags[key] = tags[keys[i]];

    reactKeys.push(key);

    str = str
      .replace(new RegExp("(<\/?)"+keys[i]+"(?:[^>\"']|\".*\"|'.*')*>", "ig"), function(match, start){
        // find/replace spell-save attributes within tag to restore capitals
        if(start !== "</")
          for(var a=0; a<tagAttributes.length; a++)
            match = replaceAttribute(match, tagAttributes[a], tagAttributes[a]);

        // replace key
        return match
          .replace(new RegExp(start+keys[i]+"(\\s|>)", "i"), start+key+"$1");
      });
  }

  // remove/disable html comments
  str = str.replace(/<!--|-->/g,"")

  // find/replace global spell-save attributes to restore capitals
  var attributes = preserveReactAttributes.concat(preserveAttributes);
  for(var i=0; i<attributes.length; i++) 
    str = replaceAttribute(str, attributes[i], attributes[i]);
 
  var jsx = htmlToJsx(str);

  // replace props variables {key} with corrected variables {props['key']}
  for(var key in props) {
    jsx = jsx
      .replace(new RegExp("(\{"+key+"\})","g"),"{props['"+key+"']}");
  }
  
  var component = ReactTransform(jsx).code;
  
  // replace component variables (ComponentName) with corrected variables (tags['ComponentName'])
  for(var i=0; i<reactKeys.length; i++) {
    component = component
      .replace(new RegExp(reactKeys[i],"g"), "reactTags['"+reactKeys[i]+"']"); 
  }

  return eval(component);
}
804012
def parse_tags(element)
      if element.class == Hash && element['string']
        if element['string'].class == Array
          return element['string'].join(", ")
        elsif element['string'].class == String 
          return element['string']
        end
      else
        return ""
      end
    end
1259410
function(obj_) {
  var obj = sg.smartAttrs(obj_ || {});

  if (!obj.tags)              { return obj; }

  var arr = obj.tags;
  if (_.isString(obj.tags)) {
    arr = obj.tags.split(/[, ]+/g);
  }

  // Turn a string into tags: 'foo, bar, baz=quxx'
  obj.tags = sg.reduce(arr, {}, function(m, str) {
    var result   = {};
    var parts    = str.split(/[=] ?/g);
    var key      = parts.shift();

    if (parts.length <= 0) {
      return sg.kv(m, key, true);
    }

    return sg.kv(m, key, parts.join('='));
  });

  return obj;
}
1176055
function(item) {
  var result = {};

  _.each(item, function(value, key) {
    if (fix[key]) {
      result[key] = parseItem(fix[key](value));
    } else if (key === 'Tags') {
      result[key] = parseTags(value);
    } else {
      result[key] = parseItem(value);
    }
  });

  return result;
}
367088
function(tag) {
    var posts = [];
    for (var key in this.posts) {
      if (this.posts[key].tags && this.posts[key].tags.indexOf(tag) !== -1) {
        posts.push(this.posts[key]);
      }
    }
    return posts;
  }
193345
function parseEndTag(tag, tagName) {

      // If no tag name is provided, clean shop
      if (!tagName)
        var pos = 0;

      // Find the closest opened tag of the same type
      else {
        tagName = tagName.toLowerCase();
        for (var pos = stack.length - 1; pos >= 0; pos--)
          if (stack[pos] == tagName)
            break;
      }

      if (pos >= 0) {
        // Close all the open elements, up the stack
        for (var i = stack.length - 1; i >= pos; i--)
          results += "</" + stack[i] + ">";

        // Remove the open elements from the stack
        stack.length = pos;
      }

    }
282455
function extractDomProperties(domNode, regex, removeDomAttributes = false) {


	if(regex && classof(regex) !== 'RegExp'){
		throw Error('Second argument is passed but it must be a Regular-Expression');
	}

	let domViewAttributes = {};
	let toBeRemovedAttributes = [];

	for(let key in domNode.attributes) {
		if(!domNode.attributes.hasOwnProperty(key)){
			continue;
		}

		let node = domNode.attributes[key];
		if(regex){
			let matched = regex.exec(node.name);
			if(matched !== null) {
				let [ ,name ] = matched;
				domViewAttributes[name] = node.value;
				removeDomAttributes ? toBeRemovedAttributes.push(node.name) : null;
			}
		}
		else if(!regex) {
			domViewAttributes[node.name] = node.value;
		}

	}

	if(removeDomAttributes){
		for(let attribute of toBeRemovedAttributes){
			domNode.removeAttribute(attribute);
		}
	}

	return domViewAttributes;

}
62941
function parseObject(tag, attrs, content, indentStr, indentLevel) {
    if (TEXT in content) {
        let args = [tag, attrs, content[TEXT], indentStr, indentLevel];
        return getType(content[TEXT])==='array' ? parseArray.apply(this, args) : renderElement.apply(this, args);
    } else {
        content = isNested(content) ? content : '';
        return renderElement(tag, attrs, content, indentStr, indentLevel);
    }
}
804441
function getAttributes(obj) {
    let attrString = '';
    let attrArray = Object.keys(obj);
    for (let tag of attrArray) {
        if (tag != ATTR && ATTRTAG.test(tag)) {
            attrString += ` ${tag.replace('_', '')}="${obj[tag]}"`;
        }
    }
    if (ATTR in obj) {
        attrString += ' ' + obj[ATTR];
    }
    return attrString;
}
896803
function attributesToJavascript(template, attr) {
	var i, name, value, js = [];
	for (i in attr) {
		if (attr.hasOwnProperty(i)) {

			// Translate
			name = Template.HTML_ATTRIBUTES[i] ? Template.HTML_ATTRIBUTES[i] : i;

			// Potentially interpolated attributes
			if (typeof attr[i] === 'string') {
				if (attr[i].length > 0) {
					js.push(JSON.stringify(name) + ':' + (ontext(template, attr[i], {virtual: false}).pop() || new VText).toJavascript());
				} else {
					js.push(JSON.stringify(name) + ':""');
				}
			} else {
				js.push(JSON.stringify(name) + ':' + JSON.stringify(attr[i]));
			}
		}
	}

	return '{' + js.join(',') + '}';
}
1195307
def tag(*tags):
    '''
    
    '''
    def dfn(fn):
        _tags = getattr(fn, 'tags', set())
        _tags.update(tags)
        fn.tags = _tags
        return fn
    return dfn
1021863
def _unparse_a_tags(cls, attrs_dict):
        
        prop_tags = []

        for k, v in attrs_dict.items():
            node = {cls.ATTRNAME_PROPERTY: k, '_content': utils.auto_type(v)}
            prop_tags.append(node)

        return prop_tags
893089
function htmlTagObjectToString (tagDefinition, xhtml) {
  const attributes = Object.keys(tagDefinition.attributes || {})
    .filter(function (attributeName) {
      return tagDefinition.attributes[attributeName] !== false;
    })
    .map(function (attributeName) {
      if (tagDefinition.attributes[attributeName] === true) {
        return xhtml ? attributeName + '="' + attributeName + '"' : attributeName;
      }
      return attributeName + '="' + tagDefinition.attributes[attributeName] + '"';
    });
  return '<' + [tagDefinition.tagName].concat(attributes).join(' ') + (tagDefinition.voidTag && xhtml ? '/' : '') + '>' +
    (tagDefinition.innerHTML || '') +
    (tagDefinition.voidTag ? '' : '</' + tagDefinition.tagName + '>');
}