src/template/compiler/languages/mustache.js
function trimWhitespace(line) {
  let whitespaceIndicies = [];
  let allWhitespace = true;
  let seenAnyTag = false;
  let newLine = new Array(line.length);
  for (let i = 0; i < line.length; i++) {
    let obj = line[i];
    newLine[i] = obj;
    if (typeof obj === 'string') {
      if (!nonWhitespace.test(obj)) {
        whitespaceIndicies.push(i);
      } else {
        allWhitespace = false;
      }
    } else {
      seenAnyTag = true;
      if (nonWhitespaceNodes[obj.type] === true) {
        allWhitespace = false;
      }
    }
    // Bail out if we've seen a non-whitespace
    if (!allWhitespace) {
      return line;
    }
  }

  // Remove the whitespace nodes if this line consists of:
  //  - only whitespace text
  //  - no Interpolators or Unescaped Interpolators
  //  - at least one Mustache tag
  if (allWhitespace && seenAnyTag) {
    for (let i = 0; i < whitespaceIndicies.length; i++) {
      let index = whitespaceIndicies[i];
      let obj = newLine[index];
      newLine[index] = {
        type: types.TEXT,
        original: obj,
        length: obj.length
      };
    }
  }

  return newLine;
}
function trimWhitespace(line) {
  let whitespaceIndicies = [];
  let allWhitespace = true;
  let seenAnyTag = false;
  let newLine = new Array(line.length);
  for (let i = 0; i < line.length; i++) {
    let obj = line[i];
    newLine[i] = obj;
    if (typeof obj === 'string') {
      if (!nonWhitespace.test(obj)) {
        whitespaceIndicies.push(i);
      } else {
        allWhitespace = false;
      }
    } else {
      seenAnyTag = true;
      if (nonWhitespaceNodes[obj.type] === true) {
        allWhitespace = false;
      }
    }
    // Bail out if we've seen a non-whitespace
    if (!allWhitespace) {
      return line;
    }
  }

  // Remove the whitespace nodes if this line consists of:
  //  - only whitespace text
  //  - no Interpolators or Unescaped Interpolators
  //  - at least one Mustache tag
  if (allWhitespace && seenAnyTag) {
    for (let i = 0; i < whitespaceIndicies.length; i++) {
      let index = whitespaceIndicies[i];
      let obj = newLine[index];
      newLine[index] = {
        type: types.TEXT,
        original: obj,
        length: obj.length
      };
    }
  }

  return newLine;
}
function trimWhitespace ( line ) { let whitespaceIndicies = [ ] ; let allWhitespace = true ; let seenAnyTag = false ; let newLine = new Array ( line . length ) ; for ( let i = 0 ; i < line . length ; i ++ ) { let obj = line [ i ] ; newLine [ i ] = obj ; if ( typeof obj === 'string' ) { if ( ! nonWhitespace . test ( obj ) ) { whitespaceIndicies . push ( i ) ; } else { allWhitespace = false ; } } else { seenAnyTag = true ; if ( nonWhitespaceNodes [ obj . type ] === true ) { allWhitespace = false ; } } // Bail out if we've seen a non-whitespace if ( ! allWhitespace ) { return line ; } } // Remove the whitespace nodes if this line consists of: //  - only whitespace text //  - no Interpolators or Unescaped Interpolators //  - at least one Mustache tag if ( allWhitespace && seenAnyTag ) { for ( let i = 0 ; i < whitespaceIndicies . length ; i ++ ) { let index = whitespaceIndicies [ i ] ; let obj = newLine [ index ] ; newLine [ index ] = { type : types . TEXT , original : obj , length : obj . length } ; } } return newLine ; }
Trims whitespace in accordance with Mustache rules
Leaves reference nodes behind for lambdas and the debugger

@param  {Array<String>} line Symbols for this line
@return {Array<String>}      Trimmed symbols for this line
Trims whitespace in accordance with Mustache rules Leaves reference nodes behind for lambdas and the debugger