lib/swig.js
function getParents(tokens, options) {
    var parentName = tokens.parent,
      parentFiles = [],
      parents = [],
      parentFile,
      parent,
      l;

    while (parentName) {
      if (!options || !options.filename) {
        throw new Error('Cannot extend "' + parentName + '" because current template has no filename.');
      }

      parentFile = parentFile || options.filename;
      parentFile = self.options.loader.resolve(parentName, parentFile);
      parent = cacheGet(parentFile, options) || self.parseFile(parentFile, utils.extend({}, options, { filename: parentFile }));
      parentName = parent.parent;

      if (parentFiles.indexOf(parentFile) !== -1) {
        throw new Error('Illegal circular extends of "' + parentFile + '".');
      }
      parentFiles.push(parentFile);

      parents.push(parent);
    }

    // Remap each parents'(1) blocks onto its own parent(2), receiving the full token list for rendering the original parent(1) on its own.
    l = parents.length;
    for (l = parents.length - 2; l >= 0; l -= 1) {
      parents[l].tokens = remapBlocks(parents[l].blocks, parents[l + 1].tokens);
      importNonBlocks(parents[l].blocks, parents[l].tokens);
    }

    return parents;
  }
function getParents(tokens, options) {
    var parentName = tokens.parent,
      parentFiles = [],
      parents = [],
      parentFile,
      parent,
      l;

    while (parentName) {
      if (!options || !options.filename) {
        throw new Error('Cannot extend "' + parentName + '" because current template has no filename.');
      }

      parentFile = parentFile || options.filename;
      parentFile = self.options.loader.resolve(parentName, parentFile);
      parent = cacheGet(parentFile, options) || self.parseFile(parentFile, utils.extend({}, options, { filename: parentFile }));
      parentName = parent.parent;

      if (parentFiles.indexOf(parentFile) !== -1) {
        throw new Error('Illegal circular extends of "' + parentFile + '".');
      }
      parentFiles.push(parentFile);

      parents.push(parent);
    }

    // Remap each parents'(1) blocks onto its own parent(2), receiving the full token list for rendering the original parent(1) on its own.
    l = parents.length;
    for (l = parents.length - 2; l >= 0; l -= 1) {
      parents[l].tokens = remapBlocks(parents[l].blocks, parents[l + 1].tokens);
      importNonBlocks(parents[l].blocks, parents[l].tokens);
    }

    return parents;
  }
function getParents ( tokens , options ) { var parentName = tokens . parent , parentFiles = [ ] , parents = [ ] , parentFile , parent , l ; while ( parentName ) { if ( ! options || ! options . filename ) { throw new Error ( 'Cannot extend "' + parentName + '" because current template has no filename.' ) ; } parentFile = parentFile || options . filename ; parentFile = self . options . loader . resolve ( parentName , parentFile ) ; parent = cacheGet ( parentFile , options ) || self . parseFile ( parentFile , utils . extend ( { } , options , { filename : parentFile } ) ) ; parentName = parent . parent ; if ( parentFiles . indexOf ( parentFile ) !== - 1 ) { throw new Error ( 'Illegal circular extends of "' + parentFile + '".' ) ; } parentFiles . push ( parentFile ) ; parents . push ( parent ) ; } // Remap each parents'(1) blocks onto its own parent(2), receiving the full token list for rendering the original parent(1) on its own. l = parents . length ; for ( l = parents . length - 2 ; l >= 0 ; l -= 1 ) { parents [ l ] . tokens = remapBlocks ( parents [ l ] . blocks , parents [ l + 1 ] . tokens ) ; importNonBlocks ( parents [ l ] . blocks , parents [ l ] . tokens ) ; } return parents ; }
Recursively compile and get parents of given parsed token object.

@param  {object} tokens    Parsed tokens from template.
@param  {SwigOpts} [options={}]   Swig options object.
@return {object}           Parsed tokens from parent templates.
@private
Recursively compile and get parents of given parsed token object .