lib/lexer.js
function(type) {
    var cached = this.regex.createClose(type);
    var file = this.file;
    var lexer = this;

    return function() {
      var pos = lexer.position();
      var m = lexer.match(cached.strict);
      if (!m) return;

      var block = lexer.tokens.pop();
      if (typeof block === 'undefined' || block.type !== type) {
        throw new Error(`missing opening ${type}`);
      }

      if (block.name === 'body') {
        lexer.ast.isLayout = true;
        file.ast.isLayout = true;
      }

      var nodes = block.nodes;
      Object.defineProperty(file.ast.blocks, block.name, {
        configurable: true,
        set: function(val) {
          nodes = val;
        },
        get: function() {
          return nodes;
        }
      });

      Object.defineProperty(block, 'nodes', {
        configurable: true,
        set: function(val) {
          nodes = val;
        },
        get: function() {
          return nodes;
        }
      });

      var tok = pos({
        known: block.known,
        type: `${type}.close`,
        val: m[0].trim()
      });

      utils.define(block, 'position', tok.position);
      utils.define(tok, 'parent', block);
      block.nodes.push(tok);
      return block;
    };
  }
function(type) {
    var cached = this.regex.createClose(type);
    var file = this.file;
    var lexer = this;

    return function() {
      var pos = lexer.position();
      var m = lexer.match(cached.strict);
      if (!m) return;

      var block = lexer.tokens.pop();
      if (typeof block === 'undefined' || block.type !== type) {
        throw new Error(`missing opening ${type}`);
      }

      if (block.name === 'body') {
        lexer.ast.isLayout = true;
        file.ast.isLayout = true;
      }

      var nodes = block.nodes;
      Object.defineProperty(file.ast.blocks, block.name, {
        configurable: true,
        set: function(val) {
          nodes = val;
        },
        get: function() {
          return nodes;
        }
      });

      Object.defineProperty(block, 'nodes', {
        configurable: true,
        set: function(val) {
          nodes = val;
        },
        get: function() {
          return nodes;
        }
      });

      var tok = pos({
        known: block.known,
        type: `${type}.close`,
        val: m[0].trim()
      });

      utils.define(block, 'position', tok.position);
      utils.define(tok, 'parent', block);
      block.nodes.push(tok);
      return block;
    };
  }
Create a closing tag lexer for block `name`.
@param {String} `name`
@return {Function}