lib/lexer.js
function() {
    if (this.isInitialized) return;

    this.isInitialized = true;
    var lexer = this;
    this.lineno = 1;
    this.column = 1;
    this.lexed = '';

    this.file = utils.normalize(this.file);
    this.file.orig = this.file.contents;
    this.input = this.file.contents.toString();
    this.file.ast = this.ast;
    this.file.ast.variables = {};
    this.file.ast.blocks = {};

    this.input = this.input.split('{% body %}')
      .join('{% block "body" %}{% endblock %}');

    if (this.file.extends) {
      this.prependNode(this.file, 'extends');
    }

    /**
     * Tags
     */
    this.captureTag('extends');
    this.captureTag('layout');

    /**
     * Block tags
     */
    this.captureBlock('block');

    /**
     * Captures
     */

    this.capture('text', utils.negateDelims(this.delimiters));
    this.capture('newline', /^\n+/);
    this.capture('es6', /^\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/);
    this.capture('variable', /^\{{2,}([^\\}]*(?:\\.[^\\}]*)*)\}{2,}/);
    this.capture('escape', /^\\(.)/);
    this.capture('space', /^[ \t]+/);

    /**
     * Custom helpers
     */
    var helpers = this.options.helpers || {};
    if (utils.isObject(helpers)) {
      helpers = Object.keys(helpers);
    }

    helpers.forEach(function(key) {
      lexer.known.blocks.push(key);
      lexer.captureBlock(key);
    });

    /**
     * Add other names to return un-rendered
     */

    var matches = this.input.match(/\{%\s*([^%}]+)/g);
    var names = utils.getNames(matches);

    names.tags.forEach(function(key) {
      if (!utils.isRegistered(lexer, key)) {
        lexer.unknown.tags.push(key);
        lexer.captureTag(key);
      }
    });

    names.blocks.forEach(function(key) {
      if (!utils.isRegistered(lexer, key)) {
        lexer.unknown.blocks.push(key);
        lexer.captureBlock(key);
      }
    });
  }
function() {
    if (this.isInitialized) return;

    this.isInitialized = true;
    var lexer = this;
    this.lineno = 1;
    this.column = 1;
    this.lexed = '';

    this.file = utils.normalize(this.file);
    this.file.orig = this.file.contents;
    this.input = this.file.contents.toString();
    this.file.ast = this.ast;
    this.file.ast.variables = {};
    this.file.ast.blocks = {};

    this.input = this.input.split('{% body %}')
      .join('{% block "body" %}{% endblock %}');

    if (this.file.extends) {
      this.prependNode(this.file, 'extends');
    }

    /**
     * Tags
     */
    this.captureTag('extends');
    this.captureTag('layout');

    /**
     * Block tags
     */
    this.captureBlock('block');

    /**
     * Captures
     */

    this.capture('text', utils.negateDelims(this.delimiters));
    this.capture('newline', /^\n+/);
    this.capture('es6', /^\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/);
    this.capture('variable', /^\{{2,}([^\\}]*(?:\\.[^\\}]*)*)\}{2,}/);
    this.capture('escape', /^\\(.)/);
    this.capture('space', /^[ \t]+/);

    /**
     * Custom helpers
     */
    var helpers = this.options.helpers || {};
    if (utils.isObject(helpers)) {
      helpers = Object.keys(helpers);
    }

    helpers.forEach(function(key) {
      lexer.known.blocks.push(key);
      lexer.captureBlock(key);
    });

    /**
     * Add other names to return un-rendered
     */

    var matches = this.input.match(/\{%\s*([^%}]+)/g);
    var names = utils.getNames(matches);

    names.tags.forEach(function(key) {
      if (!utils.isRegistered(lexer, key)) {
        lexer.unknown.tags.push(key);
        lexer.captureTag(key);
      }
    });

    names.blocks.forEach(function(key) {
      if (!utils.isRegistered(lexer, key)) {
        lexer.unknown.blocks.push(key);
        lexer.captureBlock(key);
      }
    });
  }
Create default delimiters and tags