src/template/compiler/stack.js
function processAttributeArray(attrArray) {
  let attrs = {
    'static': {},
    'dynamic': []
  };
  let name = [];
  let value = [];
  let item;
  let pushingTo = name;
  for (let i = 0; i < attrArray.length; i++) {
    item = attrArray[i];
    if (item.type === 'attributenameend') {
      pushingTo = value;
    } else if (item.type === 'attributeend') {
      // Ensure there are no tokens in a non-dynamic attribute name
      for (let j = 0; j < name.length; j++) {
        if (typeof name[j] !== 'string') {
          compilerErrors.mustacheTokenCannotBeInAttributeNames(name[j]);
        }
      }

      if (name.length === 1) {
        if (value.length) {
          if (value.length === 1 && typeof value[0] === 'string') {
            value = value[0];
          }
        } else {
          value = true;
        }
        attrs.static[name[0]] = flattenAttributeValues(value);
      } else {
        attrs.dynamic = attrs.dynamic.concat(_.map(name, flattenAttributeValues));
        if (value.length) {
          attrs.dynamic.push('="');
          attrs.dynamic = attrs.dynamic.concat(_.map(value, flattenAttributeValues));
          attrs.dynamic.push('"');
        }
      }
      name = [];
      value = [];
      pushingTo = name;
    } else if (item.type === 'attributename' || item.type === 'attributevalue') {
      pushingTo.push(item.value);
    } else if (pushingTo === name) {
      if (name.length === 0) {
        if (item.type === types.INTERPOLATOR) {
          compilerErrors.doubleCurlyInterpolatorsCannotBeInAttributes(item.value);
        } else if (item.type === types.SECTION) {
          attrs.dynamic.push(templateStack.processObject(item));
          continue;
        }
      }
      pushingTo.push(item);
    } else {
      pushingTo.push(item);
    }
  }

  attrs.dynamic = attrs.dynamic.concat(_.map(name, flattenAttributeValues));
  attrs.dynamic = attrs.dynamic.concat(_.map(value, flattenAttributeValues));
  mergeStrings(attrs.dynamic);

  return attrs;
}
function processAttributeArray(attrArray) {
  let attrs = {
    'static': {},
    'dynamic': []
  };
  let name = [];
  let value = [];
  let item;
  let pushingTo = name;
  for (let i = 0; i < attrArray.length; i++) {
    item = attrArray[i];
    if (item.type === 'attributenameend') {
      pushingTo = value;
    } else if (item.type === 'attributeend') {
      // Ensure there are no tokens in a non-dynamic attribute name
      for (let j = 0; j < name.length; j++) {
        if (typeof name[j] !== 'string') {
          compilerErrors.mustacheTokenCannotBeInAttributeNames(name[j]);
        }
      }

      if (name.length === 1) {
        if (value.length) {
          if (value.length === 1 && typeof value[0] === 'string') {
            value = value[0];
          }
        } else {
          value = true;
        }
        attrs.static[name[0]] = flattenAttributeValues(value);
      } else {
        attrs.dynamic = attrs.dynamic.concat(_.map(name, flattenAttributeValues));
        if (value.length) {
          attrs.dynamic.push('="');
          attrs.dynamic = attrs.dynamic.concat(_.map(value, flattenAttributeValues));
          attrs.dynamic.push('"');
        }
      }
      name = [];
      value = [];
      pushingTo = name;
    } else if (item.type === 'attributename' || item.type === 'attributevalue') {
      pushingTo.push(item.value);
    } else if (pushingTo === name) {
      if (name.length === 0) {
        if (item.type === types.INTERPOLATOR) {
          compilerErrors.doubleCurlyInterpolatorsCannotBeInAttributes(item.value);
        } else if (item.type === types.SECTION) {
          attrs.dynamic.push(templateStack.processObject(item));
          continue;
        }
      }
      pushingTo.push(item);
    } else {
      pushingTo.push(item);
    }
  }

  attrs.dynamic = attrs.dynamic.concat(_.map(name, flattenAttributeValues));
  attrs.dynamic = attrs.dynamic.concat(_.map(value, flattenAttributeValues));
  mergeStrings(attrs.dynamic);

  return attrs;
}
function processAttributeArray ( attrArray ) { let attrs = { 'static' : { } , 'dynamic' : [ ] } ; let name = [ ] ; let value = [ ] ; let item ; let pushingTo = name ; for ( let i = 0 ; i < attrArray . length ; i ++ ) { item = attrArray [ i ] ; if ( item . type === 'attributenameend' ) { pushingTo = value ; } else if ( item . type === 'attributeend' ) { // Ensure there are no tokens in a non-dynamic attribute name for ( let j = 0 ; j < name . length ; j ++ ) { if ( typeof name [ j ] !== 'string' ) { compilerErrors . mustacheTokenCannotBeInAttributeNames ( name [ j ] ) ; } } if ( name . length === 1 ) { if ( value . length ) { if ( value . length === 1 && typeof value [ 0 ] === 'string' ) { value = value [ 0 ] ; } } else { value = true ; } attrs . static [ name [ 0 ] ] = flattenAttributeValues ( value ) ; } else { attrs . dynamic = attrs . dynamic . concat ( _ . map ( name , flattenAttributeValues ) ) ; if ( value . length ) { attrs . dynamic . push ( '="' ) ; attrs . dynamic = attrs . dynamic . concat ( _ . map ( value , flattenAttributeValues ) ) ; attrs . dynamic . push ( '"' ) ; } } name = [ ] ; value = [ ] ; pushingTo = name ; } else if ( item . type === 'attributename' || item . type === 'attributevalue' ) { pushingTo . push ( item . value ) ; } else if ( pushingTo === name ) { if ( name . length === 0 ) { if ( item . type === types . INTERPOLATOR ) { compilerErrors . doubleCurlyInterpolatorsCannotBeInAttributes ( item . value ) ; } else if ( item . type === types . SECTION ) { attrs . dynamic . push ( templateStack . processObject ( item ) ) ; continue ; } } pushingTo . push ( item ) ; } else { pushingTo . push ( item ) ; } } attrs . dynamic = attrs . dynamic . concat ( _ . map ( name , flattenAttributeValues ) ) ; attrs . dynamic = attrs . dynamic . concat ( _ . map ( value , flattenAttributeValues ) ) ; mergeStrings ( attrs . dynamic ) ; return attrs ; }
Processes attributes into static and dynamic values
@param  {Array<Object>} attrArray Attribute array built during parsing
@return {Object}
Processes attributes into static and dynamic values