diff --git a/.eslintrc.json b/.eslintrc.json index d24c8ba4..a2f77892 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -24,4 +24,4 @@ "constructor-super": "warn", "valid-typeof": "warn" } -} \ No newline at end of file +} diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e614c79..8c1a78d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # CHANGELOG +## v4.13.0 + +1. 修复超大模板编译性能问题 [#539](https://github.com/aui/art-template/issues/539)、[#4](https://github.com/aui/express-art-template/issues/4) +2. 支持嵌套 block [#468](https://github.com/aui/art-template/issues/468) + ## v4.12.2 1. 修复 [#483](https://github.com/aui/art-template/issues/483) diff --git a/lib/compile/adapter/html-minifier.js b/lib/compile/adapter/html-minifier.js index fcd91885..bae2f9c5 100644 --- a/lib/compile/adapter/html-minifier.js +++ b/lib/compile/adapter/html-minifier.js @@ -1,5 +1,7 @@ 'use strict'; +function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + var detectNode = require('detect-node'); /** @@ -17,7 +19,7 @@ var htmlMinifier = function htmlMinifier(source, options) { var ignoreCustomFragments = options.rules.map(function (rule) { return rule.test; }); - (_htmlMinifierOptions$ = htmlMinifierOptions.ignoreCustomFragments).push.apply(_htmlMinifierOptions$, ignoreCustomFragments); + (_htmlMinifierOptions$ = htmlMinifierOptions.ignoreCustomFragments).push.apply(_htmlMinifierOptions$, _toConsumableArray(ignoreCustomFragments)); source = _htmlMinifier(source, htmlMinifierOptions); } diff --git a/lib/compile/compiler.js b/lib/compile/compiler.js index 3bcbe4f0..9eedb1f5 100644 --- a/lib/compile/compiler.js +++ b/lib/compile/compiler.js @@ -1,5 +1,11 @@ 'use strict'; +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var esTokenizer = require('./es-tokenizer'); @@ -85,13 +91,13 @@ var Compiler = function () { this.CONTEXT_MAP = {}; // 忽略的变量名单 - this.ignore = [DATA, IMPORTS, OPTIONS].concat(options.ignore); + this.ignore = [DATA, IMPORTS, OPTIONS].concat(_toConsumableArray(options.ignore)); // 按需编译到模板渲染函数的内置变量 - this.internal = (_internal = {}, _internal[OUT] = '\'\'', _internal[LINE] = '[0,0]', _internal[BLOCKS] = 'arguments[1]||{}', _internal[FROM] = 'null', _internal[PRINT] = 'function(){var s=\'\'.concat.apply(\'\',arguments);' + OUT + '+=s;return s}', _internal[INCLUDE] = 'function(src,data){var s=' + OPTIONS + '.include(src,data||' + DATA + ',arguments[2]||' + BLOCKS + ',' + OPTIONS + ');' + OUT + '+=s;return s}', _internal[EXTEND] = 'function(from){' + FROM + '=from}', _internal[SLICE] = 'function(c,p,s){p=' + OUT + ';' + OUT + '=\'\';c();s=' + OUT + ';' + OUT + '=p+s;return s}', _internal[BLOCK] = 'function(){var a=arguments,s;if(typeof a[0]===\'function\'){return ' + SLICE + '(a[0])}else if(' + FROM + '){if(!' + BLOCKS + '[a[0]]){' + BLOCKS + '[a[0]]=' + SLICE + '(a[1])}else{' + OUT + '+=' + BLOCKS + '[a[0]]}}else{s=' + BLOCKS + '[a[0]];if(typeof s===\'string\'){' + OUT + '+=s}else{s=' + SLICE + '(a[1])}return s}}', _internal); + this.internal = (_internal = {}, _defineProperty(_internal, OUT, '\'\''), _defineProperty(_internal, LINE, '[0,0]'), _defineProperty(_internal, BLOCKS, 'arguments[1]||{}'), _defineProperty(_internal, FROM, 'null'), _defineProperty(_internal, PRINT, 'function(){var s=\'\'.concat.apply(\'\',arguments);' + OUT + '+=s;return s}'), _defineProperty(_internal, INCLUDE, 'function(src,data){var s=' + OPTIONS + '.include(src,data||' + DATA + ',arguments[2]||' + BLOCKS + ',' + OPTIONS + ');' + OUT + '+=s;return s}'), _defineProperty(_internal, EXTEND, 'function(from){' + FROM + '=from}'), _defineProperty(_internal, SLICE, 'function(c,p,s){p=' + OUT + ';' + OUT + '=\'\';c();s=' + OUT + ';' + OUT + '=p+s;return s}'), _defineProperty(_internal, BLOCK, 'function(){var a=arguments,s;if(typeof a[0]===\'function\'){return ' + SLICE + '(a[0])}else if(' + FROM + '){if(!' + BLOCKS + '[a[0]]){' + BLOCKS + '[a[0]]=' + SLICE + '(a[1])}else{' + OUT + '+=' + BLOCKS + '[a[0]]}}else{s=' + BLOCKS + '[a[0]];if(typeof s===\'string\'){' + OUT + '+=s}else{s=' + SLICE + '(a[1])}return s}}'), _internal); // 内置函数依赖关系声明 - this.dependencies = (_dependencies = {}, _dependencies[PRINT] = [OUT], _dependencies[INCLUDE] = [OUT, OPTIONS, DATA, BLOCKS], _dependencies[EXTEND] = [FROM, /*[*/INCLUDE /*]*/], _dependencies[BLOCK] = [SLICE, FROM, OUT, BLOCKS], _dependencies); + this.dependencies = (_dependencies = {}, _defineProperty(_dependencies, PRINT, [OUT]), _defineProperty(_dependencies, INCLUDE, [OUT, OPTIONS, DATA, BLOCKS]), _defineProperty(_dependencies, EXTEND, [FROM, /*[*/INCLUDE /*]*/]), _defineProperty(_dependencies, BLOCK, [SLICE, FROM, OUT, BLOCKS]), _dependencies); this.importContext(OUT); @@ -122,318 +128,328 @@ var Compiler = function () { */ - Compiler.prototype.getTplTokens = function getTplTokens() { - return tplTokenizer.apply(undefined, arguments); - }; - - /** - * 将模板表达式转换成 esToken 数组 - * @param {string} source - * @return {Object[]} - */ - - - Compiler.prototype.getEsTokens = function getEsTokens(source) { - return esTokenizer(source); - }; - - /** - * 获取变量列表 - * @param {Object[]} esTokens - * @return {string[]} - */ - - - Compiler.prototype.getVariables = function getVariables(esTokens) { - var ignore = false; - return esTokens.filter(function (esToken) { - return esToken.type !== 'whitespace' && esToken.type !== 'comment'; - }).filter(function (esToken) { - if (esToken.type === 'name' && !ignore) { - return true; - } - - ignore = esToken.type === 'punctuator' && esToken.value === '.'; - - return false; - }).map(function (tooken) { - return tooken.value; - }); - }; - - /** - * 导入模板上下文 - * @param {string} name - */ - - - Compiler.prototype.importContext = function importContext(name) { - var _this2 = this; - - var value = ''; - var internal = this.internal; - var dependencies = this.dependencies; - var ignore = this.ignore; - var context = this.context; - var options = this.options; - var imports = options.imports; - var contextMap = this.CONTEXT_MAP; + _createClass(Compiler, [{ + key: 'getTplTokens', + value: function getTplTokens() { + return tplTokenizer.apply(undefined, arguments); + } - if (!has(contextMap, name) && ignore.indexOf(name) === -1) { + /** + * 将模板表达式转换成 esToken 数组 + * @param {string} source + * @return {Object[]} + */ - if (has(internal, name)) { - value = internal[name]; + }, { + key: 'getEsTokens', + value: function getEsTokens(source) { + return esTokenizer(source); + } - if (has(dependencies, name)) { - dependencies[name].forEach(function (name) { - return _this2.importContext(name); - }); + /** + * 获取变量列表 + * @param {Object[]} esTokens + * @return {string[]} + */ + + }, { + key: 'getVariables', + value: function getVariables(esTokens) { + var ignore = false; + return esTokens.filter(function (esToken) { + return esToken.type !== 'whitespace' && esToken.type !== 'comment'; + }).filter(function (esToken) { + if (esToken.type === 'name' && !ignore) { + return true; } - // imports 继承了 Global,但是继承的属性不分配到顶级变量中,避免占用了模板内部的变量名称 - } else if (name === ESCAPE || name === EACH || has(imports, name)) { - value = IMPORTS + '.' + name; - } else { - value = DATA + '.' + name; - } + ignore = esToken.type === 'punctuator' && esToken.value === '.'; - contextMap[name] = value; - context.push({ - name: name, - value: value + return false; + }).map(function (tooken) { + return tooken.value; }); } - }; - /** - * 解析字符串(HTML)直接输出语句 - * @param {Object} tplToken - */ - - - Compiler.prototype.parseString = function parseString(tplToken) { - - var source = tplToken.value; + /** + * 导入模板上下文 + * @param {string} name + */ + + }, { + key: 'importContext', + value: function importContext(name) { + var _this2 = this; + + var value = ''; + var internal = this.internal; + var dependencies = this.dependencies; + var ignore = this.ignore; + var context = this.context; + var options = this.options; + var imports = options.imports; + var contextMap = this.CONTEXT_MAP; + + if (!has(contextMap, name) && ignore.indexOf(name) === -1) { + + if (has(internal, name)) { + value = internal[name]; + + if (has(dependencies, name)) { + dependencies[name].forEach(function (name) { + return _this2.importContext(name); + }); + } + + // imports 继承了 Global,但是继承的属性不分配到顶级变量中,避免占用了模板内部的变量名称 + } else if (name === ESCAPE || name === EACH || has(imports, name)) { + value = IMPORTS + '.' + name; + } else { + value = DATA + '.' + name; + } - if (!source) { - return; + contextMap[name] = value; + context.push({ + name: name, + value: value + }); + } } - var code = OUT + '+=' + stringify(source); - this.scripts.push({ - source: source, - tplToken: tplToken, - code: code - }); - }; + /** + * 解析字符串(HTML)直接输出语句 + * @param {Object} tplToken + */ - /** - * 解析逻辑表达式语句 - * @param {Object} tplToken - */ + }, { + key: 'parseString', + value: function parseString(tplToken) { + var source = tplToken.value; - Compiler.prototype.parseExpression = function parseExpression(tplToken) { - var _this3 = this; + if (!source) { + return; + } - var source = tplToken.value; - var script = tplToken.script; - var output = script.output; - var escape = this.options.escape; - var code = script.code; + var code = OUT + '+=' + stringify(source); + this.scripts.push({ + source: source, + tplToken: tplToken, + code: code + }); + } - if (output) { - if (escape === false || output === tplTokenizer.TYPE_RAW) { - code = OUT + '+=' + script.code; - } else { - code = OUT + '+=' + ESCAPE + '(' + script.code + ')'; + /** + * 解析逻辑表达式语句 + * @param {Object} tplToken + */ + + }, { + key: 'parseExpression', + value: function parseExpression(tplToken) { + var _this3 = this; + + var source = tplToken.value; + var script = tplToken.script; + var output = script.output; + var escape = this.options.escape; + var code = script.code; + + if (output) { + if (escape === false || output === tplTokenizer.TYPE_RAW) { + code = OUT + '+=' + script.code; + } else { + code = OUT + '+=' + ESCAPE + '(' + script.code + ')'; + } } - } - var esToken = this.getEsTokens(code); - this.getVariables(esToken).forEach(function (name) { - return _this3.importContext(name); - }); + var esToken = this.getEsTokens(code); + this.getVariables(esToken).forEach(function (name) { + return _this3.importContext(name); + }); - this.scripts.push({ - source: source, - tplToken: tplToken, - code: code - }); - }; + this.scripts.push({ + source: source, + tplToken: tplToken, + code: code + }); + } - /** - * 检查解析后的模板语句是否存在语法错误 - * @param {string} script - * @return {boolean} - */ + /** + * 检查解析后的模板语句是否存在语法错误 + * @param {string} script + * @return {boolean} + */ + }, { + key: 'checkExpression', + value: function checkExpression(script) { - Compiler.prototype.checkExpression = function checkExpression(script) { + // 没有闭合的块级模板语句规则 + // 基于正则规则来补全语法不能保证 100% 准确, + // 但是在绝大多数情况下足以满足辅助开发调试的需要 + var rules = [ - // 没有闭合的块级模板语句规则 - // 基于正则规则来补全语法不能保证 100% 准确, - // 但是在绝大多数情况下足以满足辅助开发调试的需要 - var rules = [ + // <% } %> + // <% }else{ %> + // <% }else if(a){ %> + [/^\s*}[\w\W]*?{?[\s;]*$/, ''], - // <% } %> - // <% }else{ %> - // <% }else if(a){ %> - [/^\s*}[\w\W]*?{?[\s;]*$/, ''], + // <% fn(c,function(a,b){ %> + // <% fn(c, a=>{ %> + // <% fn(c,(a,b)=>{ %> + [/(^[\w\W]*?\([\w\W]*?(?:=>|\([\w\W]*?\))\s*{[\s;]*$)/, '$1})'], - // <% fn(c,function(a,b){ %> - // <% fn(c, a=>{ %> - // <% fn(c,(a,b)=>{ %> - [/(^[\w\W]*?\([\w\W]*?(?:=>|\([\w\W]*?\))\s*{[\s;]*$)/, '$1})'], + // <% if(a){ %> + // <% for(var i in d){ %> + [/(^[\w\W]*?\([\w\W]*?\)\s*{[\s;]*$)/, '$1}']]; - // <% if(a){ %> - // <% for(var i in d){ %> - [/(^[\w\W]*?\([\w\W]*?\)\s*{[\s;]*$)/, '$1}']]; + var index = 0; + while (index < rules.length) { + if (rules[index][0].test(script)) { + var _script; - var index = 0; - while (index < rules.length) { - if (rules[index][0].test(script)) { - var _script; + script = (_script = script).replace.apply(_script, _toConsumableArray(rules[index])); + break; + } + index++; + }; - script = (_script = script).replace.apply(_script, rules[index]); - break; + try { + new Function(script); + return true; + } catch (e) { + return false; } - index++; - }; - - try { - new Function(script); - return true; - } catch (e) { - return false; } - }; - - /** - * 编译 - * @return {function} - */ - - Compiler.prototype.build = function build() { - - var options = this.options; - var context = this.context; - var scripts = this.scripts; - var stacks = this.stacks; - var source = this.source; - var filename = options.filename; - var imports = options.imports; - var mappings = []; - var extendMode = has(this.CONTEXT_MAP, EXTEND); - - var offsetLine = 0; - - // Create SourceMap: mapping - var mapping = function mapping(code, _ref) { - var line = _ref.line, - start = _ref.start; + /** + * 编译 + * @return {function} + */ + + }, { + key: 'build', + value: function build() { + + var options = this.options; + var context = this.context; + var scripts = this.scripts; + var stacks = this.stacks; + var source = this.source; + var filename = options.filename; + var imports = options.imports; + var mappings = []; + var extendMode = has(this.CONTEXT_MAP, EXTEND); + + var offsetLine = 0; + + // Create SourceMap: mapping + var mapping = function mapping(code, _ref) { + var line = _ref.line, + start = _ref.start; + + var node = { + generated: { + line: stacks.length + offsetLine + 1, + column: 1 + }, + original: { + line: line + 1, + column: start + 1 + } + }; + + offsetLine += code.split(/\n/).length - 1; + return node; + }; - var node = { - generated: { - line: stacks.length + offsetLine + 1, - column: 1 - }, - original: { - line: line + 1, - column: start + 1 - } + // Trim code + var trim = function trim(code) { + return code.replace(/^[\t ]+|[\t ]$/g, ''); }; - offsetLine += code.split(/\n/).length - 1; - return node; - }; + stacks.push('function(' + DATA + '){'); + stacks.push('\'use strict\''); + stacks.push(DATA + '=' + DATA + '||{}'); + stacks.push('var ' + context.map(function (_ref2) { + var name = _ref2.name, + value = _ref2.value; + return name + '=' + value; + }).join(',')); - // Trim code - var trim = function trim(code) { - return code.replace(/^[\t ]+|[\t ]$/g, ''); - }; + if (options.compileDebug) { - stacks.push('function(' + DATA + '){'); - stacks.push('\'use strict\''); - stacks.push(DATA + '=' + DATA + '||{}'); - stacks.push('var ' + context.map(function (_ref2) { - var name = _ref2.name, - value = _ref2.value; - return name + '=' + value; - }).join(',')); + stacks.push('try{'); - if (options.compileDebug) { + scripts.forEach(function (script) { - stacks.push('try{'); + if (script.tplToken.type === tplTokenizer.TYPE_EXPRESSION) { + stacks.push(LINE + '=[' + [script.tplToken.line, script.tplToken.start].join(',') + ']'); + } - scripts.forEach(function (script) { + mappings.push(mapping(script.code, script.tplToken)); + stacks.push(trim(script.code)); + }); - if (script.tplToken.type === tplTokenizer.TYPE_EXPRESSION) { - stacks.push(LINE + '=[' + [script.tplToken.line, script.tplToken.start].join(',') + ']'); - } + stacks.push('}catch(error){'); - mappings.push(mapping(script.code, script.tplToken)); - stacks.push(trim(script.code)); - }); + stacks.push('throw {' + ['name:\'RuntimeError\'', 'path:' + stringify(filename), 'message:error.message', 'line:' + LINE + '[0]+1', 'column:' + LINE + '[1]+1', 'source:' + stringify(source), 'stack:error.stack'].join(',') + '}'); - stacks.push('}catch(error){'); + stacks.push('}'); + } else { + scripts.forEach(function (script) { + mappings.push(mapping(script.code, script.tplToken)); + stacks.push(trim(script.code)); + }); + } - stacks.push('throw {' + ['name:\'RuntimeError\'', 'path:' + stringify(filename), 'message:error.message', 'line:' + LINE + '[0]+1', 'column:' + LINE + '[1]+1', 'source:' + stringify(source), 'stack:error.stack'].join(',') + '}'); + if (extendMode) { + stacks.push(OUT + '=\'\''); + stacks.push(INCLUDE + '(' + FROM + ',' + DATA + ',' + BLOCKS + ')'); + } + stacks.push('return ' + OUT); stacks.push('}'); - } else { - scripts.forEach(function (script) { - mappings.push(mapping(script.code, script.tplToken)); - stacks.push(trim(script.code)); - }); - } - - if (extendMode) { - stacks.push(OUT + '=\'\''); - stacks.push(INCLUDE + '(' + FROM + ',' + DATA + ',' + BLOCKS + ')'); - } - - stacks.push('return ' + OUT); - stacks.push('}'); - - var renderCode = stacks.join('\n'); - try { - var result = new Function(IMPORTS, OPTIONS, 'return ' + renderCode)(imports, options); - result.mappings = mappings; - result.sourcesContent = [source]; - return result; - } catch (error) { + var renderCode = stacks.join('\n'); - var index = 0; - var line = 0; - var start = 0; - var generated = void 0; - - while (index < scripts.length) { - var current = scripts[index]; - if (!this.checkExpression(current.code)) { - line = current.tplToken.line; - start = current.tplToken.start; - generated = current.code; - break; - } - index++; - }; - - throw { - name: 'CompileError', - path: filename, - message: error.message, - line: line + 1, - column: start + 1, - source: source, - generated: generated, - stack: error.stack - }; + try { + var result = new Function(IMPORTS, OPTIONS, 'return ' + renderCode)(imports, options); + result.mappings = mappings; + result.sourcesContent = [source]; + return result; + } catch (error) { + + var index = 0; + var line = 0; + var start = 0; + var generated = void 0; + + while (index < scripts.length) { + var current = scripts[index]; + if (!this.checkExpression(current.code)) { + line = current.tplToken.line; + start = current.tplToken.start; + generated = current.code; + break; + } + index++; + }; + + throw { + name: 'CompileError', + path: filename, + message: error.message, + line: line + 1, + column: start + 1, + source: source, + generated: generated, + stack: error.stack + }; + } } - }; + }]); return Compiler; }(); diff --git a/lib/compile/error.js b/lib/compile/error.js index 7f07421b..44836609 100644 --- a/lib/compile/error.js +++ b/lib/compile/error.js @@ -16,7 +16,7 @@ var TemplateError = function (_Error) { function TemplateError(options) { _classCallCheck(this, TemplateError); - var _this = _possibleConstructorReturn(this, _Error.call(this, options.message)); + var _this = _possibleConstructorReturn(this, (TemplateError.__proto__ || Object.getPrototypeOf(TemplateError)).call(this, options.message)); _this.name = 'TemplateError'; _this.message = formatMessage(options); diff --git a/lib/compile/tpl-tokenizer.js b/lib/compile/tpl-tokenizer.js index 0c60740f..cd36356a 100644 --- a/lib/compile/tpl-tokenizer.js +++ b/lib/compile/tpl-tokenizer.js @@ -5,12 +5,32 @@ var TYPE_EXPRESSION = 'expression'; var TYPE_RAW = 'raw'; var TYPE_ESCAPE = 'escape'; -function Match(content, line, start, end) { - var match = new String(content); - match.line = line; - match.start = start; - match.end = end; - return match; +function wrapString(token) { + var value = new String(token.value); + value.line = token.line; + value.start = token.start; + value.end = token.end; + return value; +} + +function Token(type, value, prevToken) { + this.type = type; + this.value = value; + this.script = null; + + if (prevToken) { + this.line = prevToken.line + prevToken.value.split(/\n/).length - 1; + if (this.line === prevToken.line) { + this.start = prevToken.end; + } else { + this.start = prevToken.value.length - prevToken.value.lastIndexOf('\n') - 1; + } + } else { + this.line = 0; + this.start = 0; + } + + this.end = this.start + this.value.length; } /** @@ -24,82 +44,49 @@ var tplTokenizer = function tplTokenizer(source, rules) { var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; - var tokens = [{ - type: TYPE_STRING, - value: source, - line: 0, - start: 0, - end: source.length - }]; - - var walk = function walk(rule) { + var tokens = [new Token(TYPE_STRING, source)]; + for (var i = 0; i < rules.length; i++) { + var rule = rules[i]; var flags = rule.test.ignoreCase ? 'ig' : 'g'; - var pattern = rule.test.source + '|^$|[\\w\\W]'; - var group = new RegExp(pattern, flags); + var regexp = new RegExp(rule.test.source, flags); + + for (var _i = 0; _i < tokens.length; _i++) { - for (var index = 0; index < tokens.length; index++) { + var token = tokens[_i]; + var prevToken = tokens[_i - 1]; - if (tokens[index].type !== TYPE_STRING) { + if (token.type !== TYPE_STRING) { continue; } - var line = tokens[index].line; - var start = tokens[index].start; - var end = tokens[index].end; - - var matchs = tokens[index].value.match(group); + var match = void 0, + index = 0; var substitute = []; + var value = token.value; - for (var m = 0; m < matchs.length; m++) { - var value = matchs[m]; - - rule.test.lastIndex = 0; - - var values = rule.test.exec(value); - var type = values ? TYPE_EXPRESSION : TYPE_STRING; - var lastSubstitute = substitute[substitute.length - 1]; - var lastToken = lastSubstitute || tokens[index]; - var lastValue = lastToken.value; - - if (lastToken.line === line) { - start = lastSubstitute ? lastSubstitute.end : start; - } else { - start = lastValue.length - lastValue.lastIndexOf('\n') - 1; + while ((match = regexp.exec(value)) !== null) { + if (match.index > index) { + prevToken = new Token(TYPE_STRING, value.slice(index, match.index), prevToken); + substitute.push(prevToken); } - end = start + value.length; - - var token = { type: type, value: value, line: line, start: start, end: end }; - - if (type === TYPE_STRING) { - - if (lastSubstitute && lastSubstitute.type === TYPE_STRING) { - - lastSubstitute.value += value; - lastSubstitute.end += value.length; - } else { + prevToken = new Token(TYPE_EXPRESSION, match[0], prevToken); + match[0] = wrapString(prevToken); + prevToken.script = rule.use.apply(context, match); + substitute.push(prevToken); - substitute.push(token); - } - } else { - - values[0] = new Match(values[0], line, start, end); - var script = rule.use.apply(context, values); - token.script = script; - substitute.push(token); - } + index = match.index + match[0].length; + } - line += value.split(/\n/).length - 1; + if (index < value.length) { + prevToken = new Token(TYPE_STRING, value.slice(index), prevToken); + substitute.push(prevToken); } - tokens.splice.apply(tokens, [index, 1].concat(substitute)); - index += substitute.length - 1; + tokens.splice.apply(tokens, [_i, 1].concat(substitute)); + _i += substitute.length - 1; } - }; - - for (var i = 0; i < rules.length; i++) { - walk(rules[i]); } return tokens; diff --git a/lib/template-web.js b/lib/template-web.js index 0e366828..d3a33105 100644 --- a/lib/template-web.js +++ b/lib/template-web.js @@ -1,3 +1,3 @@ -/*! art-template@4.12.2 for browser | https://github.com/aui/art-template */ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.template=t():e.template=t()}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e["default"]}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=6)}([function(e,t,n){(function(t){e.exports=!1;try{e.exports="[object process]"===Object.prototype.toString.call(t.process)}catch(n){}}).call(t,n(4))},function(e,t,n){"use strict";var r=n(8),i=n(3),o=n(23),s=function(e,t){t.onerror(e,t);var n=function(){return"{Template Error}"};return n.mappings=[],n.sourcesContent=[],n},a=function c(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};"string"!=typeof e?t=e:t.source=e,t=i.$extend(t),e=t.source,!0===t.debug&&(t.cache=!1,t.minimize=!1,t.compileDebug=!0),t.compileDebug&&(t.minimize=!1),t.filename&&(t.filename=t.resolveFilename(t.filename,t));var n=t.filename,a=t.cache,u=t.caches;if(a&&n){var p=u.get(n);if(p)return p}if(!e)try{e=t.loader(n,t),t.source=e}catch(d){var l=new o({name:"CompileError",path:n,message:"template not found: "+d.message,stack:d.stack});if(t.bail)throw l;return s(l,t)}var f=void 0,h=new r(t);try{f=h.build()}catch(l){if(l=new o(l),t.bail)throw l;return s(l,t)}var m=function(e,n){try{return f(e,n)}catch(l){if(!t.compileDebug)return t.cache=!1,t.compileDebug=!0,c(t)(e,n);if(l=new o(l),t.bail)throw l;return s(l,t)()}};return m.mappings=f.mappings,m.sourcesContent=f.sourcesContent,m.toString=function(){return f.toString()},a&&n&&u.set(n,m),m};a.Compiler=r,e.exports=a},function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=/((['"])(?:(?!\2|\\).|\\(?:\r\n|[\s\S]))*(\2)?|`(?:[^`\\$]|\\[\s\S]|\$(?!\{)|\$\{(?:[^{}]|\{[^}]*\}?)*\}?)*(`)?)|(\/\/.*)|(\/\*(?:[^*]|\*(?!\/))*(\*\/)?)|(\/(?!\*)(?:\[(?:(?![\]\\]).|\\.)*\]|(?![\/\]\\]).|\\.)+\/(?:(?!\s*(?:\b|[\u0080-\uFFFF$\\'"~({]|[+\-!](?!=)|\.?\d))|[gmiyu]{1,5}\b(?![\u0080-\uFFFF$\\]|\s*(?:[+\-*%&|^<>!=?({]|\/(?![\/*])))))|(0[xX][\da-fA-F]+|0[oO][0-7]+|0[bB][01]+|(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?)|((?!\d)(?:(?!\s)[$\w\u0080-\uFFFF]|\\u[\da-fA-F]{4}|\\u\{[\da-fA-F]+\})+)|(--|\+\+|&&|\|\||=>|\.{3}|(?:[+\-\/%&|^]|\*{1,2}|<{1,2}|>{1,3}|!=?|={1,2})=?|[?~.,:;[\](){}])|(\s+)|(^$|[\s\S])/g,t.matchToToken=function(e){var t={type:"invalid",value:e[0]};return e[1]?(t.type="string",t.closed=!(!e[3]&&!e[4])):e[5]?t.type="comment":e[6]?(t.type="comment",t.closed=!!e[7]):e[8]?t.type="regex":e[9]?t.type="number":e[10]?t.type="name":e[11]?t.type="punctuator":e[12]&&(t.type="whitespace"),t}},function(e,t,n){"use strict";function r(){this.$extend=function(e){return e=e||{},s(e,e instanceof r?e:this)}}var i=n(0),o=n(12),s=n(13),a=n(14),c=n(15),u=n(16),p=n(17),l=n(18),f=n(19),h=n(20),m=n(22),d={source:null,filename:null,rules:[f,l],escape:!0,debug:!!i&&"production"!==process.env.NODE_ENV,bail:!0,cache:!0,minimize:!0,compileDebug:!1,resolveFilename:m,include:a,htmlMinifier:h,htmlMinifierOptions:{collapseWhitespace:!0,minifyCSS:!0,minifyJS:!0,ignoreCustomFragments:[]},onerror:c,loader:p,caches:u,root:"/",extname:".art",ignore:[],imports:o};r.prototype=d,e.exports=new r},function(e,t){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(r){"object"==typeof window&&(n=window)}e.exports=n},function(e,t){},function(e,t,n){"use strict";var r=n(7),i=n(1),o=n(24),s=function(e,t){return t instanceof Object?r({filename:e},t):i({filename:e,source:t})};s.render=r,s.compile=i,s.defaults=o,e.exports=s},function(e,t,n){"use strict";var r=n(1),i=function(e,t,n){return r(e,n)(t)};e.exports=i},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=n(9),o=n(11),s="$data",a="$imports",c="print",u="include",p="extend",l="block",f="$$out",h="$$line",m="$$blocks",d="$$slice",v="$$from",g="$$options",y=function(e,t){return Object.hasOwnProperty.call(e,t)},b=JSON.stringify,x=function(){function e(t){var n,i,y=this;r(this,e);var b=t.source,x=t.minimize,w=t.htmlMinifier;if(this.options=t,this.stacks=[],this.context=[],this.scripts=[],this.CONTEXT_MAP={},this.ignore=[s,a,g].concat(t.ignore),this.internal=(n={},n[f]="''",n[h]="[0,0]",n[m]="arguments[1]||{}",n[v]="null",n[c]="function(){var s=''.concat.apply('',arguments);"+f+"+=s;return s}",n[u]="function(src,data){var s="+g+".include(src,data||"+s+",arguments[2]||"+m+","+g+");"+f+"+=s;return s}",n[p]="function(from){"+v+"=from}",n[d]="function(c,p,s){p="+f+";"+f+"='';c();s="+f+";"+f+"=p+s;return s}",n[l]="function(){var a=arguments,s;if(typeof a[0]==='function'){return "+d+"(a[0])}else if("+v+"){if(!"+m+"[a[0]]){"+m+"[a[0]]="+d+"(a[1])}else{"+f+"+="+m+"[a[0]]}}else{s="+m+"[a[0]];if(typeof s==='string'){"+f+"+=s}else{s="+d+"(a[1])}return s}}",n),this.dependencies=(i={},i[c]=[f],i[u]=[f,g,s,m],i[p]=[v,u],i[l]=[d,v,f,m],i),this.importContext(f),t.compileDebug&&this.importContext(h),x)try{b=w(b,t)}catch(E){}this.source=b,this.getTplTokens(b,t.rules,this).forEach(function(e){e.type===o.TYPE_STRING?y.parseString(e):y.parseExpression(e)})}return e.prototype.getTplTokens=function(){return o.apply(undefined,arguments)},e.prototype.getEsTokens=function(e){return i(e)},e.prototype.getVariables=function(e){var t=!1;return e.filter(function(e){return"whitespace"!==e.type&&"comment"!==e.type}).filter(function(e){return"name"===e.type&&!t||(t="punctuator"===e.type&&"."===e.value,!1)}).map(function(e){return e.value})},e.prototype.importContext=function(e){var t=this,n="",r=this.internal,i=this.dependencies,o=this.ignore,c=this.context,u=this.options,p=u.imports,l=this.CONTEXT_MAP;y(l,e)||-1!==o.indexOf(e)||(y(r,e)?(n=r[e],y(i,e)&&i[e].forEach(function(e){return t.importContext(e)})):n="$escape"===e||"$each"===e||y(p,e)?a+"."+e:s+"."+e,l[e]=n,c.push({name:e,value:n}))},e.prototype.parseString=function(e){var t=e.value;if(t){var n=f+"+="+b(t);this.scripts.push({source:t,tplToken:e,code:n})}},e.prototype.parseExpression=function(e){var t=this,n=e.value,r=e.script,i=r.output,s=this.options.escape,a=r.code;i&&(a=!1===s||i===o.TYPE_RAW?f+"+="+r.code:f+"+=$escape("+r.code+")");var c=this.getEsTokens(a);this.getVariables(c).forEach(function(e){return t.importContext(e)}),this.scripts.push({source:n,tplToken:e,code:a})},e.prototype.checkExpression=function(e){for(var t=[[/^\s*}[\w\W]*?{?[\s;]*$/,""],[/(^[\w\W]*?\([\w\W]*?(?:=>|\([\w\W]*?\))\s*{[\s;]*$)/,"$1})"],[/(^[\w\W]*?\([\w\W]*?\)\s*{[\s;]*$)/,"$1}"]],n=0;n2&&arguments[2]!==undefined?arguments[2]:{},i=[{type:"string",value:e,line:0,start:0,end:e.length}],o=0;o]/;s.$escape=function(e){return i(r(e))},s.$each=function(e,t){if(Array.isArray(e))for(var n=0,r=e.length;n {{"+n+"}}")};switch("#"===t&&h("#value","@value"),f){case"set":i="var "+c.join("").trim();break;case"if":i="if("+c.join("").trim()+"){";break;case"else":var m=c.indexOf("if");~m?(c.splice(0,m+1),i="}else if("+c.join("").trim()+"){"):i="}else{";break;case"/if":i="}";break;case"each":p=r._split(a),p.shift(),"as"===p[1]&&(h("each object as value index","each object value index"),p.splice(1,1));i="$each("+(p[0]||"$data")+",function("+(p[1]||"$value")+","+(p[2]||"$index")+"){";break;case"/each":i="})";break;case"block":p=r._split(a),p.shift(),i="block("+p.join(",").trim()+",function(){";break;case"/block":i="})";break;case"echo":f="print",h("echo value","value");case"print":case"include":case"extend":if(0!==c.join("").trim().indexOf("(")){p=r._split(a),p.shift(),i=f+"("+p.join(",")+")";break}default:if(~c.indexOf("|")){var d=a.reduce(function(e,t){var n=t.value,r=t.type;return"|"===n?e.push([]):"whitespace"!==r&&"comment"!==r&&(e.length||e.push([]),":"===n&&1===e[e.length-1].length?h("value | filter: argv","value | filter argv"):e[e.length-1].push(t)),e},[]).map(function(e){return r._split(e)});i=d.reduce(function(e,t){var n=t.shift();return t.unshift(e),"$imports."+n+"("+t.join(",")+")"},d.shift().join(" ").trim())}l=l||"escape"}return u.code=i,u.output=l,u},_split:function(e){e=e.filter(function(e){var t=e.type;return"whitespace"!==t&&"comment"!==t});for(var t=0,n=e.shift(),r=/\]|\)/,i=[[n]];t/,use:function(e,t,n,r){return n={"-":"raw","=":"escape","":!1,"==":"raw","=#":"raw"}[n],t&&(r="/*"+r+"*/",n=!1),{code:r,output:n}}};e.exports=r},function(e,t,n){"use strict";var r=n(0),i=function(e,t){if(r){var i,o=n(21).minify,s=t.htmlMinifierOptions,a=t.rules.map(function(e){return e.test});(i=s.ignoreCustomFragments).push.apply(i,a),e=o(e,s)}return e};e.exports=i},function(e,t){!function(e){e.noop=function(){}}("object"==typeof e&&"object"==typeof e.exports?e.exports:window)},function(e,t,n){"use strict";var r=n(0),i=/^\.+\//,o=function(e,t){if(r){var o=n(5),s=t.root,a=t.extname;if(i.test(e)){var c=t.filename,u=!c||e===c,p=u?s:o.dirname(c);e=o.resolve(p,e)}else e=o.resolve(s,e);o.extname(e)||(e+=a)}return e};e.exports=o},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function s(e){var t=e.name,n=e.source,r=e.path,i=e.line,o=e.column,s=e.generated,a=e.message;if(!n)return a;var c=n.split(/\n/),u=Math.max(i-3,0),p=Math.min(c.length,i+3),l=c.slice(u,p).map(function(e,t){var n=t+u+1;return(n===i?" >> ":" ")+n+"| "+e}).join("\n");return(r||"anonymous")+":"+i+":"+o+"\n"+l+"\n\n"+t+": "+a+(s?"\n generated: "+s:"")}var a=function(e){function t(n){r(this,t);var o=i(this,e.call(this,n.message));return o.name="TemplateError",o.message=s(n),Error.captureStackTrace&&Error.captureStackTrace(o,o.constructor),o}return o(t,e),t}(Error);e.exports=a},function(e,t,n){"use strict";e.exports=n(3)}])}); \ No newline at end of file +/*! art-template@4.13.0 for browser | https://github.com/aui/art-template */ +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.template=t():e.template=t()}("undefined"!=typeof self?self:this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e["default"]}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=6)}([function(e,t,n){(function(t){e.exports=!1;try{e.exports="[object process]"===Object.prototype.toString.call(t.process)}catch(n){}}).call(t,n(4))},function(e,t,n){"use strict";var r=n(8),i=n(3),o=n(23),s=function(e,t){t.onerror(e,t);var n=function(){return"{Template Error}"};return n.mappings=[],n.sourcesContent=[],n},a=function u(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};"string"!=typeof e?t=e:t.source=e,t=i.$extend(t),e=t.source,!0===t.debug&&(t.cache=!1,t.minimize=!1,t.compileDebug=!0),t.compileDebug&&(t.minimize=!1),t.filename&&(t.filename=t.resolveFilename(t.filename,t));var n=t.filename,a=t.cache,c=t.caches;if(a&&n){var l=c.get(n);if(l)return l}if(!e)try{e=t.loader(n,t),t.source=e}catch(v){var f=new o({name:"CompileError",path:n,message:"template not found: "+v.message,stack:v.stack});if(t.bail)throw f;return s(f,t)}var p=void 0,h=new r(t);try{p=h.build()}catch(f){if(f=new o(f),t.bail)throw f;return s(f,t)}var m=function(e,n){try{return p(e,n)}catch(f){if(!t.compileDebug)return t.cache=!1,t.compileDebug=!0,u(t)(e,n);if(f=new o(f),t.bail)throw f;return s(f,t)()}};return m.mappings=p.mappings,m.sourcesContent=p.sourcesContent,m.toString=function(){return p.toString()},a&&n&&c.set(n,m),m};a.Compiler=r,e.exports=a},function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=/((['"])(?:(?!\2|\\).|\\(?:\r\n|[\s\S]))*(\2)?|`(?:[^`\\$]|\\[\s\S]|\$(?!\{)|\$\{(?:[^{}]|\{[^}]*\}?)*\}?)*(`)?)|(\/\/.*)|(\/\*(?:[^*]|\*(?!\/))*(\*\/)?)|(\/(?!\*)(?:\[(?:(?![\]\\]).|\\.)*\]|(?![\/\]\\]).|\\.)+\/(?:(?!\s*(?:\b|[\u0080-\uFFFF$\\'"~({]|[+\-!](?!=)|\.?\d))|[gmiyu]{1,5}\b(?![\u0080-\uFFFF$\\]|\s*(?:[+\-*%&|^<>!=?({]|\/(?![\/*])))))|(0[xX][\da-fA-F]+|0[oO][0-7]+|0[bB][01]+|(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?)|((?!\d)(?:(?!\s)[$\w\u0080-\uFFFF]|\\u[\da-fA-F]{4}|\\u\{[\da-fA-F]+\})+)|(--|\+\+|&&|\|\||=>|\.{3}|(?:[+\-\/%&|^]|\*{1,2}|<{1,2}|>{1,3}|!=?|={1,2})=?|[?~.,:;[\](){}])|(\s+)|(^$|[\s\S])/g,t.matchToToken=function(e){var t={type:"invalid",value:e[0]};return e[1]?(t.type="string",t.closed=!(!e[3]&&!e[4])):e[5]?t.type="comment":e[6]?(t.type="comment",t.closed=!!e[7]):e[8]?t.type="regex":e[9]?t.type="number":e[10]?t.type="name":e[11]?t.type="punctuator":e[12]&&(t.type="whitespace"),t}},function(e,t,n){"use strict";function r(){this.$extend=function(e){return e=e||{},s(e,e instanceof r?e:this)}}var i=n(0),o=n(12),s=n(13),a=n(14),u=n(15),c=n(16),l=n(17),f=n(18),p=n(19),h=n(20),m=n(22),v={source:null,filename:null,rules:[p,f],escape:!0,debug:!!i&&"production"!==process.env.NODE_ENV,bail:!0,cache:!0,minimize:!0,compileDebug:!1,resolveFilename:m,include:a,htmlMinifier:h,htmlMinifierOptions:{collapseWhitespace:!0,minifyCSS:!0,minifyJS:!0,ignoreCustomFragments:[]},onerror:u,loader:l,caches:c,root:"/",extname:".art",ignore:[],imports:o};r.prototype=v,e.exports=new r},function(e,t){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(r){"object"==typeof window&&(n=window)}e.exports=n},function(e,t){},function(e,t,n){"use strict";var r=n(7),i=n(1),o=n(24),s=function(e,t){return t instanceof Object?r({filename:e},t):i({filename:e,source:t})};s.render=r,s.compile=i,s.defaults=o,e.exports=s},function(e,t,n){"use strict";var r=n(1),i=function(e,t,n){return r(e,n)(t)};e.exports=i},function(e,t,n){"use strict";function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t|\([\w\W]*?\))\s*{[\s;]*$)/,"$1})"],[/(^[\w\W]*?\([\w\W]*?\)\s*{[\s;]*$)/,"$1}"]],n=0;n2&&arguments[2]!==undefined?arguments[2]:{},o=[new i("string",e)],s=0;sm&&(p=new i("string",d.slice(m,h.index),p),v.push(p)),p=new i("expression",h[0],p),h[0]=r(p),p.script=a.use.apply(n,h),v.push(p),m=h.index+h[0].length;m]/;s.$escape=function(e){return i(r(e))},s.$each=function(e,t){if(Array.isArray(e))for(var n=0,r=e.length;n {{"+n+"}}")};switch("#"===t&&h("#value","@value"),p){case"set":i="var "+u.join("").trim();break;case"if":i="if("+u.join("").trim()+"){";break;case"else":var m=u.indexOf("if");~m?(u.splice(0,m+1),i="}else if("+u.join("").trim()+"){"):i="}else{";break;case"/if":i="}";break;case"each":l=r._split(a),l.shift(),"as"===l[1]&&(h("each object as value index","each object value index"),l.splice(1,1));i="$each("+(l[0]||"$data")+",function("+(l[1]||"$value")+","+(l[2]||"$index")+"){";break;case"/each":i="})";break;case"block":l=r._split(a),l.shift(),i="block("+l.join(",").trim()+",function(){";break;case"/block":i="})";break;case"echo":p="print",h("echo value","value");case"print":case"include":case"extend":if(0!==u.join("").trim().indexOf("(")){l=r._split(a),l.shift(),i=p+"("+l.join(",")+")";break}default:if(~u.indexOf("|")){var v=a.reduce(function(e,t){var n=t.value,r=t.type;return"|"===n?e.push([]):"whitespace"!==r&&"comment"!==r&&(e.length||e.push([]),":"===n&&1===e[e.length-1].length?h("value | filter: argv","value | filter argv"):e[e.length-1].push(t)),e},[]).map(function(e){return r._split(e)});i=v.reduce(function(e,t){var n=t.shift();return t.unshift(e),"$imports."+n+"("+t.join(",")+")"},v.shift().join(" ").trim())}f=f||"escape"}return c.code=i,c.output=f,c},_split:function(e){e=e.filter(function(e){var t=e.type;return"whitespace"!==t&&"comment"!==t});for(var t=0,n=e.shift(),r=/\]|\)/,i=[[n]];t/,use:function(e,t,n,r){return n={"-":"raw","=":"escape","":!1,"==":"raw","=#":"raw"}[n],t&&(r="/*"+r+"*/",n=!1),{code:r,output:n}}};e.exports=r},function(e,t,n){"use strict";function r(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t> ":" ")+n+"| "+e}).join("\n");return(r||"anonymous")+":"+i+":"+o+"\n"+f+"\n\n"+t+": "+a+(s?"\n generated: "+s:"")}var a=function(e){function t(e){r(this,t);var n=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e.message));return n.name="TemplateError",n.message=s(e),Error.captureStackTrace&&Error.captureStackTrace(n,n.constructor),n}return o(t,e),t}(Error);e.exports=a},function(e,t,n){"use strict";e.exports=n(3)}])}); \ No newline at end of file