art-template 4.12.1 → 4.13.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/README.md +18 -20
- package/index.d.ts +109 -0
- package/index.js +1 -1
- package/lib/compile/adapter/extend.js +1 -1
- package/lib/compile/adapter/html-minifier.js +5 -3
- package/lib/compile/adapter/loader.js +1 -1
- package/lib/compile/adapter/resolve-filename.js +3 -4
- package/lib/compile/adapter/rule.art.js +0 -14
- package/lib/compile/adapter/rule.native.js +0 -1
- package/lib/compile/compiler.js +284 -277
- package/lib/compile/defaults.js +3 -4
- package/lib/compile/error.js +1 -4
- package/lib/compile/index.js +0 -5
- package/lib/compile/runtime.js +7 -7
- package/lib/compile/tpl-tokenizer.js +53 -68
- package/lib/extension.js +2 -2
- package/lib/precompile.js +41 -48
- package/lib/template-web.js +3 -3
- package/package.json +11 -10
package/lib/compile/defaults.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var detectNode = require('detect-node');
|
|
4
3
|
var runtime = require('./runtime');
|
|
5
4
|
var extend = require('./adapter/extend');
|
|
6
5
|
var include = require('./adapter/include');
|
|
@@ -12,9 +11,10 @@ var nativeRule = require('./adapter/rule.native');
|
|
|
12
11
|
var htmlMinifier = require('./adapter/html-minifier');
|
|
13
12
|
var resolveFilename = require('./adapter/resolve-filename');
|
|
14
13
|
|
|
14
|
+
var detectNode = typeof window === 'undefined';
|
|
15
|
+
|
|
15
16
|
/** 模板编译器默认配置 */
|
|
16
17
|
var settings = {
|
|
17
|
-
|
|
18
18
|
// 模板内容。如果没有此字段,则会根据 filename 来加载模板内容
|
|
19
19
|
source: null,
|
|
20
20
|
|
|
@@ -82,7 +82,6 @@ var settings = {
|
|
|
82
82
|
|
|
83
83
|
// 导入的模板变量
|
|
84
84
|
imports: runtime
|
|
85
|
-
|
|
86
85
|
};
|
|
87
86
|
|
|
88
87
|
function Defaults() {
|
|
@@ -90,7 +89,7 @@ function Defaults() {
|
|
|
90
89
|
options = options || {};
|
|
91
90
|
return extend(options, options instanceof Defaults ? options : this);
|
|
92
91
|
};
|
|
93
|
-
}
|
|
92
|
+
}
|
|
94
93
|
Defaults.prototype = settings;
|
|
95
94
|
|
|
96
95
|
module.exports = new Defaults();
|
package/lib/compile/error.js
CHANGED
|
@@ -16,7 +16,7 @@ var TemplateError = function (_Error) {
|
|
|
16
16
|
function TemplateError(options) {
|
|
17
17
|
_classCallCheck(this, TemplateError);
|
|
18
18
|
|
|
19
|
-
var _this = _possibleConstructorReturn(this,
|
|
19
|
+
var _this = _possibleConstructorReturn(this, (TemplateError.__proto__ || Object.getPrototypeOf(TemplateError)).call(this, options.message));
|
|
20
20
|
|
|
21
21
|
_this.name = 'TemplateError';
|
|
22
22
|
_this.message = formatMessage(options);
|
|
@@ -29,8 +29,6 @@ var TemplateError = function (_Error) {
|
|
|
29
29
|
return TemplateError;
|
|
30
30
|
}(Error);
|
|
31
31
|
|
|
32
|
-
;
|
|
33
|
-
|
|
34
32
|
function formatMessage(_ref) {
|
|
35
33
|
var name = _ref.name,
|
|
36
34
|
source = _ref.source,
|
|
@@ -40,7 +38,6 @@ function formatMessage(_ref) {
|
|
|
40
38
|
generated = _ref.generated,
|
|
41
39
|
message = _ref.message;
|
|
42
40
|
|
|
43
|
-
|
|
44
41
|
if (!source) {
|
|
45
42
|
return message;
|
|
46
43
|
}
|
package/lib/compile/index.js
CHANGED
|
@@ -23,7 +23,6 @@ var debugRender = function debugRender(error, options) {
|
|
|
23
23
|
var compile = function compile(source) {
|
|
24
24
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
25
25
|
|
|
26
|
-
|
|
27
26
|
if (typeof source !== 'string') {
|
|
28
27
|
options = source;
|
|
29
28
|
} else {
|
|
@@ -65,12 +64,10 @@ var compile = function compile(source) {
|
|
|
65
64
|
|
|
66
65
|
// 加载外部模板
|
|
67
66
|
if (!source) {
|
|
68
|
-
|
|
69
67
|
try {
|
|
70
68
|
source = options.loader(filename, options);
|
|
71
69
|
options.source = source;
|
|
72
70
|
} catch (e) {
|
|
73
|
-
|
|
74
71
|
var error = new TemplateError({
|
|
75
72
|
name: 'CompileError',
|
|
76
73
|
path: filename,
|
|
@@ -101,11 +98,9 @@ var compile = function compile(source) {
|
|
|
101
98
|
}
|
|
102
99
|
|
|
103
100
|
var render = function render(data, blocks) {
|
|
104
|
-
|
|
105
101
|
try {
|
|
106
102
|
return fn(data, blocks);
|
|
107
103
|
} catch (error) {
|
|
108
|
-
|
|
109
104
|
// 运行时出错以调试模式重载
|
|
110
105
|
if (!options.compileDebug) {
|
|
111
106
|
options.cache = false;
|
package/lib/compile/runtime.js
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
/*! art-template@runtime | https://github.com/aui/art-template */
|
|
4
4
|
|
|
5
|
-
var
|
|
6
|
-
|
|
5
|
+
var globalThis = typeof self !== 'undefined' ? self : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : {};
|
|
6
|
+
|
|
7
|
+
var runtime = Object.create(globalThis);
|
|
7
8
|
var ESCAPE_REG = /["&'<>]/;
|
|
8
9
|
|
|
9
10
|
/**
|
|
@@ -17,8 +18,8 @@ runtime.$escape = function (content) {
|
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
20
|
* 迭代器,支持数组与对象
|
|
20
|
-
* @param {array|Object} data
|
|
21
|
-
* @param {function} callback
|
|
21
|
+
* @param {array|Object} data
|
|
22
|
+
* @param {function} callback
|
|
22
23
|
*/
|
|
23
24
|
runtime.$each = function (data, callback) {
|
|
24
25
|
if (Array.isArray(data)) {
|
|
@@ -45,7 +46,7 @@ function toString(value) {
|
|
|
45
46
|
}
|
|
46
47
|
|
|
47
48
|
return value;
|
|
48
|
-
}
|
|
49
|
+
}
|
|
49
50
|
|
|
50
51
|
// 编码 HTML 内容
|
|
51
52
|
function xmlEscape(content) {
|
|
@@ -60,7 +61,6 @@ function xmlEscape(content) {
|
|
|
60
61
|
lastIndex = void 0,
|
|
61
62
|
char = void 0;
|
|
62
63
|
for (i = regexResult.index, lastIndex = 0; i < html.length; i++) {
|
|
63
|
-
|
|
64
64
|
switch (html.charCodeAt(i)) {
|
|
65
65
|
case 34:
|
|
66
66
|
char = '"';
|
|
@@ -94,6 +94,6 @@ function xmlEscape(content) {
|
|
|
94
94
|
} else {
|
|
95
95
|
return result;
|
|
96
96
|
}
|
|
97
|
-
}
|
|
97
|
+
}
|
|
98
98
|
|
|
99
99
|
module.exports = runtime;
|
|
@@ -5,17 +5,37 @@ var TYPE_EXPRESSION = 'expression';
|
|
|
5
5
|
var TYPE_RAW = 'raw';
|
|
6
6
|
var TYPE_ESCAPE = 'escape';
|
|
7
7
|
|
|
8
|
-
function
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return
|
|
8
|
+
function wrapString(token) {
|
|
9
|
+
var value = new String(token.value);
|
|
10
|
+
value.line = token.line;
|
|
11
|
+
value.start = token.start;
|
|
12
|
+
value.end = token.end;
|
|
13
|
+
return value;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function Token(type, value, prevToken) {
|
|
17
|
+
this.type = type;
|
|
18
|
+
this.value = value;
|
|
19
|
+
this.script = null;
|
|
20
|
+
|
|
21
|
+
if (prevToken) {
|
|
22
|
+
this.line = prevToken.line + prevToken.value.split(/\n/).length - 1;
|
|
23
|
+
if (this.line === prevToken.line) {
|
|
24
|
+
this.start = prevToken.end;
|
|
25
|
+
} else {
|
|
26
|
+
this.start = prevToken.value.length - prevToken.value.lastIndexOf('\n') - 1;
|
|
27
|
+
}
|
|
28
|
+
} else {
|
|
29
|
+
this.line = 0;
|
|
30
|
+
this.start = 0;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
this.end = this.start + this.value.length;
|
|
14
34
|
}
|
|
15
35
|
|
|
16
36
|
/**
|
|
17
37
|
* 将模板转换为 Tokens
|
|
18
|
-
* @param {string} source
|
|
38
|
+
* @param {string} source
|
|
19
39
|
* @param {Object[]} rules @see defaults.rules
|
|
20
40
|
* @param {Object} context
|
|
21
41
|
* @return {Object[]}
|
|
@@ -23,83 +43,48 @@ function Match(content, line, start, end) {
|
|
|
23
43
|
var tplTokenizer = function tplTokenizer(source, rules) {
|
|
24
44
|
var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
25
45
|
|
|
46
|
+
var tokens = [new Token(TYPE_STRING, source)];
|
|
26
47
|
|
|
27
|
-
var
|
|
28
|
-
|
|
29
|
-
value: source,
|
|
30
|
-
line: 0,
|
|
31
|
-
start: 0,
|
|
32
|
-
end: source.length
|
|
33
|
-
}];
|
|
34
|
-
|
|
35
|
-
var walk = function walk(rule) {
|
|
36
|
-
|
|
48
|
+
for (var i = 0; i < rules.length; i++) {
|
|
49
|
+
var rule = rules[i];
|
|
37
50
|
var flags = rule.test.ignoreCase ? 'ig' : 'g';
|
|
38
|
-
var
|
|
39
|
-
var group = new RegExp(pattern, flags);
|
|
51
|
+
var regexp = new RegExp(rule.test.source, flags);
|
|
40
52
|
|
|
41
|
-
for (var
|
|
53
|
+
for (var _i = 0; _i < tokens.length; _i++) {
|
|
54
|
+
var token = tokens[_i];
|
|
55
|
+
var prevToken = tokens[_i - 1];
|
|
42
56
|
|
|
43
|
-
if (
|
|
57
|
+
if (token.type !== TYPE_STRING) {
|
|
44
58
|
continue;
|
|
45
59
|
}
|
|
46
60
|
|
|
47
|
-
var
|
|
48
|
-
|
|
49
|
-
var end = tokens[index].end;
|
|
50
|
-
|
|
51
|
-
var matchs = tokens[index].value.match(group);
|
|
61
|
+
var match = void 0,
|
|
62
|
+
index = 0;
|
|
52
63
|
var substitute = [];
|
|
64
|
+
var value = token.value;
|
|
53
65
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
var values = rule.test.exec(value);
|
|
60
|
-
var type = values ? TYPE_EXPRESSION : TYPE_STRING;
|
|
61
|
-
var lastSubstitute = substitute[substitute.length - 1];
|
|
62
|
-
var lastToken = lastSubstitute || tokens[index];
|
|
63
|
-
var lastValue = lastToken.value;
|
|
64
|
-
|
|
65
|
-
if (lastToken.line === line) {
|
|
66
|
-
start = lastSubstitute ? lastSubstitute.end : start;
|
|
67
|
-
} else {
|
|
68
|
-
start = lastValue.length - lastValue.lastIndexOf('\n') - 1;
|
|
66
|
+
while ((match = regexp.exec(value)) !== null) {
|
|
67
|
+
if (match.index > index) {
|
|
68
|
+
prevToken = new Token(TYPE_STRING, value.slice(index, match.index), prevToken);
|
|
69
|
+
substitute.push(prevToken);
|
|
69
70
|
}
|
|
70
71
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
if (type === TYPE_STRING) {
|
|
76
|
-
|
|
77
|
-
if (lastSubstitute && lastSubstitute.type === TYPE_STRING) {
|
|
78
|
-
|
|
79
|
-
lastSubstitute.value += value;
|
|
80
|
-
lastSubstitute.end += value.length;
|
|
81
|
-
} else {
|
|
72
|
+
prevToken = new Token(TYPE_EXPRESSION, match[0], prevToken);
|
|
73
|
+
match[0] = wrapString(prevToken);
|
|
74
|
+
prevToken.script = rule.use.apply(context, match);
|
|
75
|
+
substitute.push(prevToken);
|
|
82
76
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
} else {
|
|
86
|
-
|
|
87
|
-
values[0] = new Match(values[0], line, start, end);
|
|
88
|
-
var script = rule.use.apply(context, values);
|
|
89
|
-
token.script = script;
|
|
90
|
-
substitute.push(token);
|
|
91
|
-
}
|
|
77
|
+
index = match.index + match[0].length;
|
|
78
|
+
}
|
|
92
79
|
|
|
93
|
-
|
|
80
|
+
if (index < value.length) {
|
|
81
|
+
prevToken = new Token(TYPE_STRING, value.slice(index), prevToken);
|
|
82
|
+
substitute.push(prevToken);
|
|
94
83
|
}
|
|
95
84
|
|
|
96
|
-
tokens.splice.apply(tokens, [
|
|
97
|
-
|
|
85
|
+
tokens.splice.apply(tokens, [_i, 1].concat(substitute));
|
|
86
|
+
_i += substitute.length - 1;
|
|
98
87
|
}
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
for (var i = 0; i < rules.length; i++) {
|
|
102
|
-
walk(rules[i]);
|
|
103
88
|
}
|
|
104
89
|
|
|
105
90
|
return tokens;
|
package/lib/extension.js
CHANGED
|
@@ -5,8 +5,8 @@ var templatePath = require.resolve('./index.js');
|
|
|
5
5
|
/**
|
|
6
6
|
* require.extensions 扩展注册函数
|
|
7
7
|
* 使用动态编译机制
|
|
8
|
-
* @param {Object} module
|
|
9
|
-
* @param {string} flnm
|
|
8
|
+
* @param {Object} module
|
|
9
|
+
* @param {string} flnm
|
|
10
10
|
*/
|
|
11
11
|
var extension = function extension(module, flnm) {
|
|
12
12
|
var filename = flnm || module.filename;
|
package/lib/precompile.js
CHANGED
|
@@ -81,7 +81,6 @@ var getOldSourceMap = function getOldSourceMap(mappings, _ref) {
|
|
|
81
81
|
var precompile = function precompile() {
|
|
82
82
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
83
83
|
|
|
84
|
-
|
|
85
84
|
if (typeof options.filename !== 'string') {
|
|
86
85
|
throw Error('template.precompile(): "options.filename" required');
|
|
87
86
|
}
|
|
@@ -112,36 +111,35 @@ var precompile = function precompile() {
|
|
|
112
111
|
var extendNode = null;
|
|
113
112
|
var enter = function enter(node) {
|
|
114
113
|
if (node.type === 'VariableDeclarator' && functions.indexOf(node.id.name) !== -1) {
|
|
115
|
-
|
|
116
114
|
// TODO 对变量覆盖进行抛错
|
|
117
115
|
if (node.id.name === CONSTS.INCLUDE) {
|
|
118
|
-
node[
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
116
|
+
node['init'] = {
|
|
117
|
+
type: 'FunctionExpression',
|
|
118
|
+
params: [{
|
|
119
|
+
type: 'Identifier',
|
|
120
|
+
name: 'content'
|
|
123
121
|
}],
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
122
|
+
body: {
|
|
123
|
+
type: 'BlockStatement',
|
|
124
|
+
body: [{
|
|
125
|
+
type: 'ExpressionStatement',
|
|
126
|
+
expression: {
|
|
127
|
+
type: 'AssignmentExpression',
|
|
128
|
+
operator: '+=',
|
|
129
|
+
left: {
|
|
130
|
+
type: 'Identifier',
|
|
131
|
+
name: CONSTS.OUT
|
|
134
132
|
},
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
133
|
+
right: {
|
|
134
|
+
type: 'Identifier',
|
|
135
|
+
name: 'content'
|
|
138
136
|
}
|
|
139
137
|
}
|
|
140
138
|
}, {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
139
|
+
type: 'ReturnStatement',
|
|
140
|
+
argument: {
|
|
141
|
+
type: 'Identifier',
|
|
142
|
+
name: CONSTS.OUT
|
|
145
143
|
}
|
|
146
144
|
}]
|
|
147
145
|
}
|
|
@@ -151,49 +149,45 @@ var precompile = function precompile() {
|
|
|
151
149
|
this.remove();
|
|
152
150
|
}
|
|
153
151
|
} else if (node.type === 'CallExpression' && node.callee.type === 'Identifier' && functions.indexOf(node.callee.name) !== -1) {
|
|
154
|
-
|
|
155
152
|
var replaceNode = void 0;
|
|
156
153
|
switch (node.callee.name) {
|
|
157
|
-
|
|
158
154
|
case CONSTS.EXTEND:
|
|
159
|
-
|
|
160
155
|
extendNode = convertFilenameNode(node.arguments[0], options);
|
|
161
156
|
replaceNode = {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
157
|
+
type: 'AssignmentExpression',
|
|
158
|
+
operator: '=',
|
|
159
|
+
left: {
|
|
160
|
+
type: 'Identifier',
|
|
161
|
+
name: CONSTS.FROM
|
|
167
162
|
},
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
163
|
+
right: {
|
|
164
|
+
type: 'Literal',
|
|
165
|
+
value: true
|
|
171
166
|
}
|
|
172
167
|
};
|
|
173
168
|
|
|
174
169
|
break;
|
|
175
170
|
|
|
176
171
|
case CONSTS.INCLUDE:
|
|
177
|
-
|
|
178
172
|
var filename = node.arguments.shift();
|
|
179
173
|
var filenameNode = filename.name === CONSTS.FROM ? extendNode : convertFilenameNode(filename, options);
|
|
180
174
|
var paramNodes = node.arguments.length ? node.arguments : [{
|
|
181
|
-
|
|
182
|
-
|
|
175
|
+
type: 'Identifier',
|
|
176
|
+
name: CONSTS.DATA
|
|
183
177
|
}];
|
|
184
178
|
|
|
185
179
|
replaceNode = node;
|
|
186
|
-
replaceNode[
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
180
|
+
replaceNode['arguments'] = [{
|
|
181
|
+
type: 'CallExpression',
|
|
182
|
+
callee: {
|
|
183
|
+
type: 'CallExpression',
|
|
184
|
+
callee: {
|
|
185
|
+
type: 'Identifier',
|
|
186
|
+
name: 'require'
|
|
193
187
|
},
|
|
194
|
-
|
|
188
|
+
arguments: [filenameNode]
|
|
195
189
|
},
|
|
196
|
-
|
|
190
|
+
arguments: paramNodes
|
|
197
191
|
}];
|
|
198
192
|
|
|
199
193
|
break;
|
|
@@ -208,7 +202,6 @@ var precompile = function precompile() {
|
|
|
208
202
|
});
|
|
209
203
|
|
|
210
204
|
if (options.sourceMap) {
|
|
211
|
-
|
|
212
205
|
var sourceRoot = options.sourceRoot;
|
|
213
206
|
var source = path.relative(sourceRoot, options.filename);
|
|
214
207
|
var file = path.basename(source);
|
package/lib/template-web.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/*! art-template@4.
|
|
2
|
-
!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 e.hasOwnProperty(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+"){"+m+"[a[0]]="+d+"(a[1])}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;n<t.length;){if(t[n][0].test(e)){var r;e=(r=e).replace.apply(r,t[n]);break}n++}try{return new Function(e),!0}catch(i){return!1}},e.prototype.build=function(){var e=this.options,t=this.context,n=this.scripts,r=this.stacks,i=this.source,c=e.filename,l=e.imports,d=[],x=y(this.CONTEXT_MAP,p),w=0,E=function(e,t){var n=t.line,i=t.start,o={generated:{line:r.length+w+1,column:1},original:{line:n+1,column:i+1}};return w+=e.split(/\n/).length-1,o},k=function(e){return e.replace(/^[\t ]+|[\t ]$/g,"")};r.push("function("+s+"){"),r.push("'use strict'"),r.push(s+"="+s+"||{}"),r.push("var "+t.map(function(e){return e.name+"="+e.value}).join(",")),e.compileDebug?(r.push("try{"),n.forEach(function(e){e.tplToken.type===o.TYPE_EXPRESSION&&r.push(h+"=["+[e.tplToken.line,e.tplToken.start].join(",")+"]"),d.push(E(e.code,e.tplToken)),r.push(k(e.code))}),r.push("}catch(error){"),r.push("throw {"+["name:'RuntimeError'","path:"+b(c),"message:error.message","line:"+h+"[0]+1","column:"+h+"[1]+1","source:"+b(i),"stack:error.stack"].join(",")+"}"),r.push("}")):n.forEach(function(e){d.push(E(e.code,e.tplToken)),r.push(k(e.code))}),x&&(r.push(f+"=''"),r.push(u+"("+v+","+s+","+m+")")),r.push("return "+f),r.push("}");var T=r.join("\n");try{var O=new Function(a,g,"return "+T)(l,e);return O.mappings=d,O.sourcesContent=[i],O}catch(F){for(var $=0,j=0,S=0,_=void 0;$<n.length;){var C=n[$];if(!this.checkExpression(C.code)){j=C.tplToken.line,S=C.tplToken.start,_=C.code;break}$++}throw{name:"CompileError",path:c,message:F.message,line:j+1,column:S+1,source:i,generated:_,stack:F.stack}}},e}();x.CONSTS={DATA:s,IMPORTS:a,PRINT:c,INCLUDE:u,EXTEND:p,BLOCK:l,OPTIONS:g,OUT:f,LINE:h,BLOCKS:m,SLICE:d,FROM:v,ESCAPE:"$escape",EACH:"$each"},e.exports=x},function(e,t,n){"use strict";var r=n(10),i=n(2)["default"],o=n(2).matchToToken,s=function(e){return e.match(i).map(function(e){return i.lastIndex=0,o(i.exec(e))}).map(function(e){return"name"===e.type&&r(e.value)&&(e.type="keyword"),e})};e.exports=s},function(e,t,n){"use strict";var r={"abstract":!0,await:!0,"boolean":!0,"break":!0,"byte":!0,"case":!0,"catch":!0,"char":!0,"class":!0,"const":!0,"continue":!0,"debugger":!0,"default":!0,"delete":!0,"do":!0,"double":!0,"else":!0,"enum":!0,"export":!0,"extends":!0,"false":!0,"final":!0,"finally":!0,"float":!0,"for":!0,"function":!0,"goto":!0,"if":!0,"implements":!0,"import":!0,"in":!0,"instanceof":!0,"int":!0,"interface":!0,"let":!0,"long":!0,"native":!0,"new":!0,"null":!0,"package":!0,"private":!0,"protected":!0,"public":!0,"return":!0,"short":!0,"static":!0,"super":!0,"switch":!0,"synchronized":!0,"this":!0,"throw":!0,"transient":!0,"true":!0,"try":!0,"typeof":!0,"var":!0,"void":!0,"volatile":!0,"while":!0,"with":!0,"yield":!0};e.exports=function(e){return r.hasOwnProperty(e)}},function(e,t,n){"use strict";function r(e,t,n,r){var i=new String(e);return i.line=t,i.start=n,i.end=r,i}var i=function(e,t){for(var n=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{},i=[{type:"string",value:e,line:0,start:0,end:e.length}],o=0;o<t.length;o++)!function(e){for(var t=e.test.ignoreCase?"ig":"g",o=e.test.source+"|^$|[\\w\\W]",s=new RegExp(o,t),a=0;a<i.length;a++)if("string"===i[a].type){for(var c=i[a].line,u=i[a].start,p=i[a].end,l=i[a].value.match(s),f=[],h=0;h<l.length;h++){var m=l[h];e.test.lastIndex=0;var d=e.test.exec(m),v=d?"expression":"string",g=f[f.length-1],y=g||i[a],b=y.value;u=y.line===c?g?g.end:u:b.length-b.lastIndexOf("\n")-1,p=u+m.length;var x={type:v,value:m,line:c,start:u,end:p};if("string"===v)g&&"string"===g.type?(g.value+=m,g.end+=m.length):f.push(x);else{d[0]=new r(d[0],c,u,p);var w=e.use.apply(n,d);x.script=w,f.push(x)}c+=m.split(/\n/).length-1}i.splice.apply(i,[a,1].concat(f)),a+=f.length-1}}(t[o]);return i};i.TYPE_STRING="string",i.TYPE_EXPRESSION="expression",i.TYPE_RAW="raw",i.TYPE_ESCAPE="escape",e.exports=i},function(e,t,n){"use strict";(function(t){function r(e){return"string"!=typeof e&&(e=e===undefined||null===e?"":"function"==typeof e?r(e.call(e)):JSON.stringify(e)),e}function i(e){var t=""+e,n=a.exec(t);if(!n)return e;var r="",i=void 0,o=void 0,s=void 0;for(i=n.index,o=0;i<t.length;i++){switch(t.charCodeAt(i)){case 34:s=""";break;case 38:s="&";break;case 39:s="'";break;case 60:s="<";break;case 62:s=">";break;default:continue}o!==i&&(r+=t.substring(o,i)),o=i+1,r+=s}return o!==i?r+t.substring(o,i):r}/*! art-template@runtime | https://github.com/aui/art-template */
|
|
3
|
-
var
|
|
1
|
+
/*! art-template@4.13.2 for browser | https://github.com/aui/art-template */
|
|
2
|
+
!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=4)}([function(e,t,n){"use strict";var r=n(6),i=n(2),o=n(22),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(m){var f=new o({name:"CompileError",path:n,message:"template not found: "+m.message,stack:m.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 d=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 d.mappings=p.mappings,d.sourcesContent=p.sourcesContent,d.toString=function(){return p.toString()},a&&n&&c.set(n,d),d};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||{},o(e,e instanceof r?e:this)}}var i=n(10),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(21),d="undefined"==typeof window,m={source:null,filename:null,rules:[f,l],escape:!0,debug:!!d&&"production"!==process.env.NODE_ENV,bail:!0,cache:!0,minimize:!0,compileDebug:!1,resolveFilename:h,include:s,htmlMinifier:p,htmlMinifierOptions:{collapseWhitespace:!0,minifyCSS:!0,minifyJS:!0,ignoreCustomFragments:[]},onerror:a,loader:c,caches:u,root:"/",extname:".art",ignore:[],imports:i};r.prototype=m,e.exports=new r},function(e,t){},function(e,t,n){"use strict";var r=n(5),i=n(0),o=n(23),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(0),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<e.length;t++)n[t]=e[t];return n}return Array.from(e)}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var s=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=n(7),u=n(9),c="$data",l="$imports",f="print",p="include",h="extend",d="block",m="$$out",v="$$line",g="$$blocks",y="$$slice",b="$$from",w="$$options",x=function(e,t){return Object.hasOwnProperty.call(e,t)},k=JSON.stringify,E=function(){function e(t){var n,s,a=this;o(this,e);var x=t.source,k=t.minimize,E=t.htmlMinifier;if(this.options=t,this.stacks=[],this.context=[],this.scripts=[],this.CONTEXT_MAP={},this.ignore=[c,l,w].concat(i(t.ignore)),this.internal=(n={},r(n,m,"''"),r(n,v,"[0,0]"),r(n,g,"arguments[1]||{}"),r(n,b,"null"),r(n,f,"function(){var s=''.concat.apply('',arguments);"+m+"+=s;return s}"),r(n,p,"function(src,data){var s="+w+".include(src,data||"+c+",arguments[2]||"+g+","+w+");"+m+"+=s;return s}"),r(n,h,"function(from){"+b+"=from}"),r(n,y,"function(c,p,s){p="+m+";"+m+"='';c();s="+m+";"+m+"=p+s;return s}"),r(n,d,"function(){var a=arguments,s;if(typeof a[0]==='function'){return "+y+"(a[0])}else if("+b+"){if(!"+g+"[a[0]]){"+g+"[a[0]]="+y+"(a[1])}else{"+m+"+="+g+"[a[0]]}}else{s="+g+"[a[0]];if(typeof s==='string'){"+m+"+=s}else{s="+y+"(a[1])}return s}}"),n),this.dependencies=(s={},r(s,f,[m]),r(s,p,[m,w,c,g]),r(s,h,[b,p]),r(s,d,[y,b,m,g]),s),this.importContext(m),t.compileDebug&&this.importContext(v),k)try{x=E(x,t)}catch(T){}this.source=x,this.getTplTokens(x,t.rules,this).forEach(function(e){e.type===u.TYPE_STRING?a.parseString(e):a.parseExpression(e)})}return s(e,[{key:"getTplTokens",value:function(){return u.apply(undefined,arguments)}},{key:"getEsTokens",value:function(e){return a(e)}},{key:"getVariables",value: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})}},{key:"importContext",value:function(e){var t=this,n="",r=this.internal,i=this.dependencies,o=this.ignore,s=this.context,a=this.options,u=a.imports,f=this.CONTEXT_MAP;x(f,e)||-1!==o.indexOf(e)||(x(r,e)?(n=r[e],x(i,e)&&i[e].forEach(function(e){return t.importContext(e)})):n="$escape"===e||"$each"===e||x(u,e)?l+"."+e:c+"."+e,f[e]=n,s.push({name:e,value:n}))}},{key:"parseString",value:function(e){var t=e.value;if(t){var n=m+"+="+k(t);this.scripts.push({source:t,tplToken:e,code:n})}}},{key:"parseExpression",value:function(e){var t=this,n=e.value,r=e.script,i=r.output,o=this.options.escape,s=r.code;i&&(s=!1===o||i===u.TYPE_RAW?m+"+="+r.code:m+"+=$escape("+r.code+")");var a=this.getEsTokens(s);this.getVariables(a).forEach(function(e){return t.importContext(e)}),this.scripts.push({source:n,tplToken:e,code:s})}},{key:"checkExpression",value: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;n<t.length;){if(t[n][0].test(e)){var r;e=(r=e).replace.apply(r,i(t[n]));break}n++}try{return new Function(e),!0}catch(o){return!1}}},{key:"build",value:function(){var e=this.options,t=this.context,n=this.scripts,r=this.stacks,i=this.source,o=e.filename,s=e.imports,a=[],f=x(this.CONTEXT_MAP,h),d=0,y=function(e,t){var n=t.line,i=t.start,o={generated:{line:r.length+d+1,column:1},original:{line:n+1,column:i+1}};return d+=e.split(/\n/).length-1,o},E=function(e){return e.replace(/^[\t ]+|[\t ]$/g,"")};r.push("function("+c+"){"),r.push("'use strict'"),r.push(c+"="+c+"||{}"),r.push("var "+t.map(function(e){return e.name+"="+e.value}).join(",")),e.compileDebug?(r.push("try{"),n.forEach(function(e){e.tplToken.type===u.TYPE_EXPRESSION&&r.push(v+"=["+[e.tplToken.line,e.tplToken.start].join(",")+"]"),a.push(y(e.code,e.tplToken)),r.push(E(e.code))}),r.push("}catch(error){"),r.push("throw {"+["name:'RuntimeError'","path:"+k(o),"message:error.message","line:"+v+"[0]+1","column:"+v+"[1]+1","source:"+k(i),"stack:error.stack"].join(",")+"}"),r.push("}")):n.forEach(function(e){a.push(y(e.code,e.tplToken)),r.push(E(e.code))}),f&&(r.push(m+"=''"),r.push(p+"("+b+","+c+","+g+")")),r.push("return "+m),r.push("}");var T=r.join("\n");try{var O=new Function(l,w,"return "+T)(s,e);return O.mappings=a,O.sourcesContent=[i],O}catch(P){for(var $=0,j=0,_=0,S=void 0;$<n.length;){var C=n[$];if(!this.checkExpression(C.code)){j=C.tplToken.line,_=C.tplToken.start,S=C.code;break}$++}throw{name:"CompileError",path:o,message:P.message,line:j+1,column:_+1,source:i,generated:S,stack:P.stack}}}}]),e}();E.CONSTS={DATA:c,IMPORTS:l,PRINT:f,INCLUDE:p,EXTEND:h,BLOCK:d,OPTIONS:w,OUT:m,LINE:v,BLOCKS:g,SLICE:y,FROM:b,ESCAPE:"$escape",EACH:"$each"},e.exports=E},function(e,t,n){"use strict";var r=n(8),i=n(1)["default"],o=n(1).matchToToken,s=function(e){return e.match(i).map(function(e){return i.lastIndex=0,o(i.exec(e))}).map(function(e){return"name"===e.type&&r(e.value)&&(e.type="keyword"),e})};e.exports=s},function(e,t,n){"use strict";var r={"abstract":!0,await:!0,"boolean":!0,"break":!0,"byte":!0,"case":!0,"catch":!0,"char":!0,"class":!0,"const":!0,"continue":!0,"debugger":!0,"default":!0,"delete":!0,"do":!0,"double":!0,"else":!0,"enum":!0,"export":!0,"extends":!0,"false":!0,"final":!0,"finally":!0,"float":!0,"for":!0,"function":!0,"goto":!0,"if":!0,"implements":!0,"import":!0,"in":!0,"instanceof":!0,"int":!0,"interface":!0,"let":!0,"long":!0,"native":!0,"new":!0,"null":!0,"package":!0,"private":!0,"protected":!0,"public":!0,"return":!0,"short":!0,"static":!0,"super":!0,"switch":!0,"synchronized":!0,"this":!0,"throw":!0,"transient":!0,"true":!0,"try":!0,"typeof":!0,"var":!0,"void":!0,"volatile":!0,"while":!0,"with":!0,"yield":!0};e.exports=function(e){return r.hasOwnProperty(e)}},function(e,t,n){"use strict";function r(e){var t=new String(e.value);return t.line=e.line,t.start=e.start,t.end=e.end,t}function i(e,t,n){this.type=e,this.value=t,this.script=null,n?(this.line=n.line+n.value.split(/\n/).length-1,this.line===n.line?this.start=n.end:this.start=n.value.length-n.value.lastIndexOf("\n")-1):(this.line=0,this.start=0),this.end=this.start+this.value.length}var o=function(e,t){for(var n=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{},o=[new i("string",e)],s=0;s<t.length;s++)for(var a=t[s],u=a.test.ignoreCase?"ig":"g",c=new RegExp(a.test.source,u),l=0;l<o.length;l++){var f=o[l],p=o[l-1];if("string"===f.type){for(var h=void 0,d=0,m=[],v=f.value;null!==(h=c.exec(v));)h.index>d&&(p=new i("string",v.slice(d,h.index),p),m.push(p)),p=new i("expression",h[0],p),h[0]=r(p),p.script=a.use.apply(n,h),m.push(p),d=h.index+h[0].length;d<v.length&&(p=new i("string",v.slice(d),p),m.push(p)),o.splice.apply(o,[l,1].concat(m)),l+=m.length-1}}return o};o.TYPE_STRING="string",o.TYPE_EXPRESSION="expression",o.TYPE_RAW="raw",o.TYPE_ESCAPE="escape",e.exports=o},function(e,t,n){"use strict";(function(t){function n(e){return"string"!=typeof e&&(e=e===undefined||null===e?"":"function"==typeof e?n(e.call(e)):JSON.stringify(e)),e}function r(e){var t=""+e,n=s.exec(t);if(!n)return e;var r="",i=void 0,o=void 0,a=void 0;for(i=n.index,o=0;i<t.length;i++){switch(t.charCodeAt(i)){case 34:a=""";break;case 38:a="&";break;case 39:a="'";break;case 60:a="<";break;case 62:a=">";break;default:continue}o!==i&&(r+=t.substring(o,i)),o=i+1,r+=a}return o!==i?r+t.substring(o,i):r}/*! art-template@runtime | https://github.com/aui/art-template */
|
|
3
|
+
var i="undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==t?t:{},o=Object.create(i),s=/["&'<>]/;o.$escape=function(e){return r(n(e))},o.$each=function(e,t){if(Array.isArray(e))for(var n=0,r=e.length;n<r;n++)t(e[n],n);else for(var i in e)t(e[i],i)},e.exports=o}).call(t,n(11))},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,n){"use strict";var r=Object.prototype.toString,i=function(e){return null===e?"Null":r.call(e).slice(8,-1)},o=function s(e,t){var n=void 0,r=i(e);if("Object"===r?n=Object.create(t||{}):"Array"===r&&(n=[].concat(t||[])),n){for(var o in e)Object.hasOwnProperty.call(e,o)&&(n[o]=s(e[o],n[o]));return n}return e};e.exports=o},function(e,t,n){"use strict";var r=function(e,t,r,i){var o=n(0);return i=i.$extend({filename:i.resolveFilename(e,i),bail:!0,source:null}),o(i)(t,r)};e.exports=r},function(e,t,n){"use strict";var r=function(e){console.error(e.name,e.message)};e.exports=r},function(e,t,n){"use strict";var r={__data:Object.create(null),set:function(e,t){this.__data[e]=t},get:function(e){return this.__data[e]},reset:function(){this.__data={}}};e.exports=r},function(e,t,n){"use strict";var r="undefined"==typeof window,i=function(e){if(r){return n(3).readFileSync(e,"utf8")}var t=document.getElementById(e);return t.value||t.innerHTML};e.exports=i},function(e,t,n){"use strict";var r={test:/{{([@#]?)[ \t]*(\/?)([\w\W]*?)[ \t]*}}/,use:function(e,t,n,i){var o=this,s=o.options,a=o.getEsTokens(i),u=a.map(function(e){return e.value}),c={},l=void 0,f=!!t&&"raw",p=n+u.shift(),h=function(t,n){console.warn((s.filename||"anonymous")+":"+(e.line+1)+":"+(e.start+1)+"\nTemplate upgrade: {{"+t+"}} -> {{"+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 d=u.indexOf("if");~d?(u.splice(0,d+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 m=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=m.reduce(function(e,t){var n=t.shift();return t.unshift(e),"$imports."+n+"("+t.join(",")+")"},m.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<e.length;){var o=e[t];"punctuator"===o.type||"punctuator"===n.type&&!r.test(n.value)?i[i.length-1].push(o):i.push([o]),n=o,t++}return i.map(function(e){return e.map(function(e){return e.value}).join("")})}};e.exports=r},function(e,t,n){"use strict";var r={test:/<%(#?)((?:==|=#|[=-])?)[ \t]*([\w\W]*?)[ \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<e.length;t++)n[t]=e[t];return n}return Array.from(e)}var i="undefined"==typeof window,o=function(e,t){if(i){var o,s=n(20).minify,a=t.htmlMinifierOptions,u=t.rules.map(function(e){return e.test});(o=a.ignoreCustomFragments).push.apply(o,r(u)),e=s(e,a)}return e};e.exports=o},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="undefined"==typeof window,i=/^\.+\//,o=function(e,t){if(r){var o=n(3),s=t.root,a=t.extname;if(i.test(e)){var u=t.filename,c=!u||e===u,l=c?s:o.dirname(u);e=o.resolve(l,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 u=n.split(/\n/),c=Math.max(i-3,0),l=Math.min(u.length,i+3),f=u.slice(c,l).map(function(e,t){var n=t+c+1;return(n===i?" >> ":" ")+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(2)}])});
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "art-template",
|
|
3
|
+
"typings": "index.d.ts",
|
|
3
4
|
"description": "JavaScript Template Engine",
|
|
4
5
|
"homepage": "http://aui.github.com/art-template/",
|
|
5
|
-
"version": "4.
|
|
6
|
+
"version": "4.13.2",
|
|
6
7
|
"keywords": [
|
|
7
8
|
"template"
|
|
8
9
|
],
|
|
@@ -13,22 +14,22 @@
|
|
|
13
14
|
},
|
|
14
15
|
"scripts": {
|
|
15
16
|
"build": "npm run build-lib && npm run build-web",
|
|
16
|
-
"build-lib": "rm -rf lib && babel src --out-dir lib
|
|
17
|
+
"build-lib": "rm -rf lib && babel src --out-dir lib",
|
|
17
18
|
"build-web": "export NODE_ENV=production && webpack",
|
|
18
|
-
"dev": "babel src --watch --out-dir lib
|
|
19
|
+
"dev": "babel src --watch --out-dir lib",
|
|
19
20
|
"test": "export NODE_ENV=production && istanbul cover node_modules/mocha/bin/_mocha -- --ui exports --colors 'test/**/*.js'",
|
|
20
21
|
"coverage": "cat ./coverage/lcov.info | coveralls"
|
|
21
22
|
},
|
|
22
23
|
"main": "index.js",
|
|
23
24
|
"files": [
|
|
24
|
-
"lib/"
|
|
25
|
+
"lib/",
|
|
26
|
+
"index.d.ts"
|
|
25
27
|
],
|
|
26
28
|
"engines": {
|
|
27
29
|
"node": ">= 1.0.0"
|
|
28
30
|
},
|
|
29
31
|
"dependencies": {
|
|
30
32
|
"acorn": "^5.0.3",
|
|
31
|
-
"detect-node": "^2.0.3",
|
|
32
33
|
"escodegen": "^1.8.1",
|
|
33
34
|
"estraverse": "^4.2.0",
|
|
34
35
|
"html-minifier": "^3.4.3",
|
|
@@ -38,16 +39,16 @@
|
|
|
38
39
|
"source-map": "^0.5.6"
|
|
39
40
|
},
|
|
40
41
|
"devDependencies": {
|
|
41
|
-
"babel-cli": "^6.
|
|
42
|
-
"babel-
|
|
43
|
-
"babel-preset-es2015": "^6.24.1",
|
|
44
|
-
"babel-preset-es2015-loose": "^8.0.0",
|
|
42
|
+
"babel-cli": "^6.26.0",
|
|
43
|
+
"babel-preset-env": "^1.7.0",
|
|
45
44
|
"coveralls": "^2.13.0",
|
|
46
45
|
"eslint": "^3.19.0",
|
|
47
46
|
"eslint-loader": "^1.7.1",
|
|
47
|
+
"eslint-plugin-prettier": "^2.6.2",
|
|
48
48
|
"istanbul": "^0.4.5",
|
|
49
|
-
"mocha": "^
|
|
49
|
+
"mocha": "^5.2.0",
|
|
50
50
|
"node-noop": "^1.0.0",
|
|
51
|
+
"prettier": "^1.14.2",
|
|
51
52
|
"webpack": "^3.0.0"
|
|
52
53
|
},
|
|
53
54
|
"license": "MIT"
|