isite 2025.1.11 → 2025.1.13

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/lib/parser.js CHANGED
@@ -1,914 +1,929 @@
1
1
  module.exports = function init(req, res, ____0, route) {
2
- req.features = req.features || [];
2
+ req.features = req.features || [];
3
3
 
4
- let parser = {};
4
+ let parser = {};
5
5
 
6
- function renderVar(v) {
7
- if (v && v == '*') {
8
- return JSON.stringify(____0.var);
9
- }
10
- return ____0.var(v);
11
- }
12
-
13
- function renderParam(v) {
14
- if (typeof req.paramsRaw[v] !== undefined) {
15
- if (v && v == '*') {
16
- return JSON.stringify(req.paramsRaw);
17
- }
18
- return req.paramsRaw[v];
6
+ function renderVar(v) {
7
+ if (v && v == '*') {
8
+ return JSON.stringify(____0.var);
9
+ }
10
+ return ____0.var(v);
19
11
  }
20
12
 
21
- return ' ';
22
- }
13
+ function renderParam(v) {
14
+ if (typeof req.paramsRaw[v] !== undefined) {
15
+ if (v && v == '*') {
16
+ return JSON.stringify(req.paramsRaw);
17
+ }
18
+ return req.paramsRaw[v];
19
+ }
23
20
 
24
- function renderQuery(v) {
25
- if (typeof req.queryRaw[v] !== undefined) {
26
- if (v && v == '*') {
27
- return JSON.stringify(req.queryRaw);
28
- }
29
- return req.queryRaw[v];
21
+ return ' ';
30
22
  }
31
- return ' ';
32
- }
33
23
 
34
- function renderData(d) {
35
- if (!d) {
36
- return '';
24
+ function renderQuery(v) {
25
+ if (typeof req.queryRaw[v] !== undefined) {
26
+ if (v && v == '*') {
27
+ return JSON.stringify(req.queryRaw);
28
+ }
29
+ return req.queryRaw[v];
30
+ }
31
+ return ' ';
37
32
  }
38
- let hide = false;
39
- let out = '';
40
33
 
41
- if (d.indexOf('#') == 0) {
42
- d = d.replace('#', '');
43
- hide = true;
44
- }
34
+ function renderData(d) {
35
+ if (!d) {
36
+ return '';
37
+ }
38
+ let hide = false;
39
+ let out = '';
45
40
 
46
- if (d == '*') {
47
- out = JSON.stringify(req.data);
48
- } else if (d) {
49
- v = d.split('.');
41
+ if (d.indexOf('#') == 0) {
42
+ d = d.replace('#', '');
43
+ hide = true;
44
+ }
50
45
 
51
- if (v.length > 0) {
52
- out = req.data[v[0]];
53
- }
46
+ if (d == '*') {
47
+ out = JSON.stringify(req.data);
48
+ } else if (d) {
49
+ v = d.split('.');
54
50
 
55
- if (v.length > 1 && out) {
56
- out = out[v[1]];
57
- }
51
+ if (v.length > 0) {
52
+ out = req.data[v[0]];
53
+ }
58
54
 
59
- if (v.length > 2 && out) {
60
- out = out[v[2]];
61
- }
55
+ if (v.length > 1 && out) {
56
+ out = out[v[1]];
57
+ }
62
58
 
63
- if (v.length > 3 && out) {
64
- out = out[v[3]];
65
- }
59
+ if (v.length > 2 && out) {
60
+ out = out[v[2]];
61
+ }
66
62
 
67
- if (v.length > 4 && out) {
68
- out = out[v[4]];
69
- }
63
+ if (v.length > 3 && out) {
64
+ out = out[v[3]];
65
+ }
70
66
 
71
- if (v.length > 5 && out) {
72
- out = out[v[5]];
73
- }
74
- }
67
+ if (v.length > 4 && out) {
68
+ out = out[v[4]];
69
+ }
75
70
 
76
- if (hide) {
77
- out = ____0.hide(out);
78
- } else {
79
- if (typeof out === 'object') {
80
- out = ____0.toJson(out);
81
- }
82
- }
71
+ if (v.length > 5 && out) {
72
+ out = out[v[5]];
73
+ }
74
+ }
83
75
 
84
- return out || '';
85
- }
76
+ if (hide) {
77
+ out = ____0.hide(out);
78
+ } else {
79
+ if (typeof out === 'object') {
80
+ out = ____0.toJson(out);
81
+ }
82
+ }
86
83
 
87
- function renderUser(v) {
88
- if (!v) {
89
- return '';
84
+ return out || '';
90
85
  }
91
86
 
92
- let user = req.session.user;
93
- if (user) {
94
- let hide = false;
95
- let out = '';
96
- if (v.indexOf('#') == 0) {
97
- v = v.replace('#', '');
98
- hide = true;
99
- }
100
- if (v == '*') {
101
- out = JSON.stringify(user);
102
- } else {
103
- v = v.split('.');
104
-
105
- if (v.length > 0) {
106
- out = user[v[0]];
87
+ function renderUser(v) {
88
+ if (!v) {
89
+ return '';
107
90
  }
108
91
 
109
- if (v.length > 1 && out) {
110
- out = out[v[1]];
111
- }
92
+ let user = req.session.user;
93
+ if (user) {
94
+ let hide = false;
95
+ let out = '';
96
+ if (v.indexOf('#') == 0) {
97
+ v = v.replace('#', '');
98
+ hide = true;
99
+ }
100
+ if (v == '*') {
101
+ out = JSON.stringify(user);
102
+ } else {
103
+ v = v.split('.');
104
+
105
+ if (v.length > 0) {
106
+ out = user[v[0]];
107
+ }
108
+
109
+ if (v.length > 1 && out) {
110
+ out = out[v[1]];
111
+ }
112
+
113
+ if (v.length > 2 && out) {
114
+ out = out[v[2]];
115
+ }
116
+
117
+ if (v.length > 3 && out) {
118
+ out = out[v[3]];
119
+ }
120
+
121
+ if (v.length > 4 && out) {
122
+ out = out[v[4]];
123
+ }
124
+
125
+ if (v.length > 5 && out) {
126
+ out = out[v[5]];
127
+ }
128
+ }
112
129
 
113
- if (v.length > 2 && out) {
114
- out = out[v[2]];
115
- }
130
+ if (typeof out === 'object') {
131
+ out = ____0.toJson(out);
132
+ }
116
133
 
117
- if (v.length > 3 && out) {
118
- out = out[v[3]];
134
+ if (hide) {
135
+ out = ____0.hide(out);
136
+ } else {
137
+ if (typeof out === 'object') {
138
+ out = ____0.toJson(out);
139
+ }
140
+ if (typeof out === 'undefined') {
141
+ out = '';
142
+ }
143
+ }
144
+ return out;
119
145
  }
120
146
 
121
- if (v.length > 4 && out) {
122
- out = out[v[4]];
123
- }
147
+ return '';
148
+ }
124
149
 
125
- if (v.length > 5 && out) {
126
- out = out[v[5]];
150
+ function render_site(v) {
151
+ if (!v) {
152
+ return '';
153
+ }
154
+ let hide = false;
155
+ let out = '';
156
+ if (v.indexOf('#') == 0) {
157
+ v = v.replace('#', '');
158
+ hide = true;
127
159
  }
128
- }
160
+ if (v == '*') {
161
+ out = JSON.stringify(____0);
162
+ } else {
163
+ v = v.split('.');
129
164
 
130
- if (typeof out === 'object') {
131
- out = ____0.toJson(out);
132
- }
165
+ if (v.length > 0) {
166
+ out = ____0[v[0]];
167
+ }
168
+
169
+ if (v.length > 1 && out) {
170
+ out = out[v[1]];
171
+ }
172
+
173
+ if (v.length > 2 && out) {
174
+ out = out[v[2]];
175
+ }
176
+
177
+ if (v.length > 3 && out) {
178
+ out = out[v[3]];
179
+ }
180
+
181
+ if (v.length > 4 && out) {
182
+ out = out[v[4]];
183
+ }
184
+
185
+ if (v.length > 5 && out) {
186
+ out = out[v[5]];
187
+ }
188
+ }
133
189
 
134
- if (hide) {
135
- out = ____0.hide(out);
136
- } else {
137
190
  if (typeof out === 'object') {
138
- out = ____0.toJson(out);
191
+ out = ____0.toJson(out);
139
192
  }
140
- if (typeof out === 'undefined') {
141
- out = '';
193
+
194
+ if (hide) {
195
+ out = ____0.hide(out);
196
+ } else {
197
+ if (typeof out === 'object') {
198
+ out = ____0.toJson(out);
199
+ }
142
200
  }
143
- }
144
- return out;
201
+ return out;
145
202
  }
146
203
 
147
- return '';
148
- }
149
-
150
- function render_site(v) {
151
- if (!v) {
152
- return '';
153
- }
154
- let hide = false;
155
- let out = '';
156
- if (v.indexOf('#') == 0) {
157
- v = v.replace('#', '');
158
- hide = true;
159
- }
160
- if (v == '*') {
161
- out = JSON.stringify(____0);
162
- } else {
163
- v = v.split('.');
164
-
165
- if (v.length > 0) {
166
- out = ____0[v[0]];
167
- }
168
-
169
- if (v.length > 1 && out) {
170
- out = out[v[1]];
171
- }
172
-
173
- if (v.length > 2 && out) {
174
- out = out[v[2]];
175
- }
176
-
177
- if (v.length > 3 && out) {
178
- out = out[v[3]];
179
- }
180
-
181
- if (v.length > 4 && out) {
182
- out = out[v[4]];
183
- }
184
-
185
- if (v.length > 5 && out) {
186
- out = out[v[5]];
187
- }
204
+ function renderSetting(v) {
205
+ if (v && v == '*') {
206
+ return JSON.stringify(____0.setting);
207
+ } else {
208
+ return render_site('setting.' + v);
209
+ }
188
210
  }
211
+ function renderRequest(v) {
212
+ if (!v) {
213
+ return '';
214
+ }
215
+ let hide = false;
216
+ let out = '';
217
+ if (v.indexOf('#') == 0) {
218
+ v = v.replace('#', '');
219
+ hide = true;
220
+ }
221
+ if (v == '*') {
222
+ out = JSON.stringify(req);
223
+ } else {
224
+ v = v.split('.');
189
225
 
190
- if (typeof out === 'object') {
191
- out = ____0.toJson(out);
192
- }
226
+ if (v.length > 0) {
227
+ out = req[v[0]];
228
+ }
193
229
 
194
- if (hide) {
195
- out = ____0.hide(out);
196
- } else {
197
- if (typeof out === 'object') {
198
- out = ____0.toJson(out);
199
- }
200
- }
201
- return out;
202
- }
203
-
204
- function renderSetting(v) {
205
- if (v && v == '*') {
206
- return JSON.stringify(____0.setting);
207
- } else {
208
- return render_site('setting.' + v);
209
- }
210
- }
211
- function renderRequest(v) {
212
- if (!v) {
213
- return '';
214
- }
215
- let hide = false;
216
- let out = '';
217
- if (v.indexOf('#') == 0) {
218
- v = v.replace('#', '');
219
- hide = true;
220
- }
221
- if (v == '*') {
222
- out = JSON.stringify(req);
223
- } else {
224
- v = v.split('.');
225
-
226
- if (v.length > 0) {
227
- out = req[v[0]];
228
- }
229
-
230
- if (v.length > 1 && out) {
231
- out = out[v[1]];
232
- }
233
-
234
- if (v.length > 2 && out) {
235
- out = out[v[2]];
236
- }
237
-
238
- if (v.length > 3 && out) {
239
- out = out[v[3]];
240
- }
241
-
242
- if (v.length > 4 && out) {
243
- out = out[v[4]];
244
- }
245
-
246
- if (v.length > 5 && out) {
247
- out = out[v[5]];
248
- }
249
- }
230
+ if (v.length > 1 && out) {
231
+ out = out[v[1]];
232
+ }
250
233
 
251
- if (hide) {
252
- out = ____0.hide(out);
253
- } else {
254
- if (typeof out === 'object') {
255
- out = ____0.toJson(out);
256
- }
257
- }
258
- return typeof out !== 'undefined' ? out : '';
259
- }
260
-
261
- function renderSession(v) {
262
- if (v && v == '*') {
263
- return JSON.stringify({
264
- accessToken: req.session.accessToken,
265
- createdTime: req.session.createdTime,
266
- modifiedTime: req.session.modifiedTime,
267
- data: req.session.data,
268
- requestesCount: req.session.requestesCount,
269
- busy: req.session.$busy,
270
- ip: req.session.ip,
271
- });
272
- }
273
- if (v == 'lang') {
274
- return req.session.language.id;
275
- } else if (v == 'theme') {
276
- return req.session.theme;
277
- } else {
278
- v = v.split('.');
279
- if (v.length === 1) {
280
- return req.session[v[0]];
281
- }
282
- if (v.length === 2) {
283
- let s1 = req.session[v[0]];
284
- if (s1) {
285
- return s1[v[1]];
234
+ if (v.length > 2 && out) {
235
+ out = out[v[2]];
236
+ }
237
+
238
+ if (v.length > 3 && out) {
239
+ out = out[v[3]];
240
+ }
241
+
242
+ if (v.length > 4 && out) {
243
+ out = out[v[4]];
244
+ }
245
+
246
+ if (v.length > 5 && out) {
247
+ out = out[v[5]];
248
+ }
249
+ }
250
+
251
+ if (hide) {
252
+ out = ____0.hide(out);
286
253
  } else {
287
- return '';
254
+ if (typeof out === 'object') {
255
+ out = ____0.toJson(out);
256
+ }
257
+ }
258
+ return typeof out !== 'undefined' ? out : '';
259
+ }
260
+
261
+ function renderSession(v) {
262
+ if (v && v == '*') {
263
+ return JSON.stringify({
264
+ accessToken: req.session.accessToken,
265
+ createdTime: req.session.createdTime,
266
+ modifiedTime: req.session.modifiedTime,
267
+ data: req.session.data,
268
+ requestesCount: req.session.requestesCount,
269
+ busy: req.session.$busy,
270
+ ip: req.session.ip,
271
+ });
272
+ }
273
+ if (v == 'lang') {
274
+ return req.session.language.id;
275
+ } else if (v == 'theme') {
276
+ return req.session.theme;
277
+ } else {
278
+ v = v.split('.');
279
+ if (v.length === 1) {
280
+ return req.session[v[0]];
281
+ }
282
+ if (v.length === 2) {
283
+ let s1 = req.session[v[0]];
284
+ if (s1) {
285
+ return s1[v[1]];
286
+ } else {
287
+ return '';
288
+ }
289
+ }
288
290
  }
289
- }
290
- }
291
- }
292
-
293
- function renderJson(name) {
294
- return ____0.readFileSync(route.parserDir + '/json/' + name + '.json');
295
- }
296
-
297
- function renderWord(name) {
298
- return req.word(name);
299
- }
300
-
301
- function getContent(name) {
302
- let path = null;
303
- let hide = false;
304
- if (name.startsWith('#')) {
305
- hide = true;
306
- name = name.replace('#', '');
307
291
  }
308
292
 
309
- if (!path || !____0.isFileExistsSync(path)) {
310
- let arr = name.split('/');
311
- if (arr.length === 1) {
312
- path = ____0.path.join(____0.path.dirname(route.parserDir), 'site_files', ____0.path.extname(arr[0]).replace('.', ''), arr[0]);
313
- } else if (arr.length === 2) {
314
- path = ____0.path.join(____0.path.dirname(route.parserDir), 'site_files', ____0.path.extname(arr[1]).replace('.', ''), arr[0], arr[1]);
315
- } else if (arr.length === 3) {
316
- path = ____0.path.join(____0.path.dirname(route.parserDir), 'site_files', ____0.path.extname(arr[2]).replace('.', ''), arr[0], arr[1], arr[2]);
317
- }
293
+ function renderJson(name) {
294
+ return ____0.readFileSync(route.parserDir + '/json/' + name + '.json');
318
295
  }
319
296
 
320
- if (!____0.isFileExistsSync(path)) {
321
- let arr = name.split('/');
322
- if (arr.length === 1) {
323
- path = ____0.path.join(route.parserDir, arr[0]);
324
- } else if (arr.length === 2) {
325
- path = ____0.path.join(____0.path.dirname(route.parserDir), 'apps', arr[0], 'site_files', ____0.path.extname(arr[1]).replace('.', ''), arr[1]);
326
- } else if (arr.length === 3) {
327
- path = ____0.path.join(____0.path.dirname(route.parserDir), 'apps', arr[0], 'site_files', ____0.path.extname(arr[2]).replace('.', ''), arr[1], arr[2]);
328
- }
297
+ function renderWord(name) {
298
+ return req.word(name);
329
299
  }
330
300
 
331
- if (!____0.isFileExistsSync(path)) {
332
- let arr = name.split('/');
333
- if (arr.length > 1) {
334
- ____0.apps.forEach((ap) => {
335
- if (arr.length === 2 && ap.name == arr[0]) {
336
- path = ____0.path.join(ap.path, 'site_files', ____0.path.extname(arr[1]).replace('.', ''), arr[1]);
337
- } else if (arr.length === 2 && ap.name2 == arr[0]) {
338
- path = ____0.path.join(ap.path, 'site_files', ____0.path.extname(arr[1]).replace('.', ''), arr[1]);
339
- } else if (arr.length === 3 && ap.name == arr[0]) {
340
- path = ____0.path.join(ap.path, 'site_files', ____0.path.extname(arr[2]).replace('.', ''), arr[1], arr[2]);
341
- }
342
- });
343
- }
344
- }
301
+ function getContent(name) {
302
+ let path = null;
303
+ let hide = false;
304
+ if (name.startsWith('#')) {
305
+ hide = true;
306
+ name = name.replace('#', '');
307
+ }
345
308
 
346
- if (!____0.isFileExistsSync(path)) {
347
- ____0.log(path, 'PATH NOT EXISTS parser.getContent()');
348
- return '';
349
- }
309
+ if (!path || !____0.isFileExistsSync(path)) {
310
+ let arr = name.split('/');
311
+ if (arr.length === 1) {
312
+ path = ____0.path.join(____0.path.dirname(route.parserDir), 'site_files', ____0.path.extname(arr[0]).replace('.', ''), arr[0]);
313
+ } else if (arr.length === 2) {
314
+ path = ____0.path.join(____0.path.dirname(route.parserDir), 'site_files', ____0.path.extname(arr[1]).replace('.', ''), arr[0], arr[1]);
315
+ } else if (arr.length === 3) {
316
+ path = ____0.path.join(____0.path.dirname(route.parserDir), 'site_files', ____0.path.extname(arr[2]).replace('.', ''), arr[0], arr[1], arr[2]);
317
+ }
318
+ }
350
319
 
351
- if (name.endsWith('.content.html')) {
352
- let txt = ____0.readFileSync(path);
353
- return txt;
354
- } else if (name.endsWith('.html')) {
355
- let txt = ____0.readFileSync(path);
356
- let $ = ____0.$.load(txt, null, false);
357
- $ = renderHtml($);
358
- if (hide) {
359
- return ____0.hide($.html());
360
- }
361
- return $.html();
362
- } else if (name.endsWith('.js')) {
363
- let txt = ____0.readFileSync(path);
364
- txt = parser.js(txt);
365
- if (hide) {
366
- txt = ____0.hide(txt);
367
- }
368
- return txt;
369
- } else if (name.endsWith('.css')) {
370
- let txt = ____0.readFileSync(path);
371
- txt = parser.css(txt);
372
- return txt;
373
- } else {
374
- let txt = ____0.readFileSync(path);
375
- if (hide) {
376
- txt = ____0.hide(txt);
377
- }
378
- return txt;
379
- }
380
- }
381
-
382
- function handleXList1($, el, data) {
383
- let property = $(el).attr('x-list1').split('.');
384
- $(el).removeAttr('x-list1');
385
- let list = null;
386
- let html2 = '';
387
- if (property.length > 0) {
388
- if (property[0] == '*') {
389
- list = data;
390
- } else {
391
- list = data[property[0]];
392
- }
393
- }
394
- if (list && property.length > 1) {
395
- list = list[property[1]];
396
- }
397
- if (list && property.length > 2) {
398
- list = list[property[2]];
399
- }
400
- if (Array.isArray(list)) {
401
- let matches = $.html(el).match(/##item1.*?##/g);
402
- list.forEach((item, i) => {
403
- $(el).attr('x-item1', i);
404
- let _html = $.html(el);
405
- if (matches) {
406
- for (let i = 0; i < matches.length; i++) {
407
- let p = matches[i].replace('##item1.', '').replace('##', '').split('.');
408
- let v = null;
409
- if (p.length > 0) {
410
- if (p[0] == '*' || !p[0]) {
411
- v = item;
412
- } else {
413
- v = item[p[0]];
414
- }
415
- }
416
- if (p.length > 1 && v) {
417
- v = v[p[1]];
418
- }
419
- if (p.length > 2 && v) {
420
- v = v[p[2]];
421
- }
422
-
423
- _html = _html.replace(matches[i], v || '');
424
- }
425
- }
426
- let $2 = ____0.$.load(_html);
427
- $2('[x-show-item1]').each(function (i, elem) {
428
- let property = $(elem).attr('x-show-item1').split('.');
429
- let out = null;
430
- if (property.length > 0) {
431
- if (property.length > 0) {
432
- out = item[property[0]];
320
+ if (!____0.isFileExistsSync(path)) {
321
+ let arr = name.split('/');
322
+ if (arr.length === 1) {
323
+ path = ____0.path.join(route.parserDir, arr[0]);
324
+ } else if (arr.length === 2) {
325
+ path = ____0.path.join(____0.path.dirname(route.parserDir), 'apps', arr[0], 'site_files', ____0.path.extname(arr[1]).replace('.', ''), arr[1]);
326
+ } else if (arr.length === 3) {
327
+ path = ____0.path.join(____0.path.dirname(route.parserDir), 'apps', arr[0], 'site_files', ____0.path.extname(arr[2]).replace('.', ''), arr[1], arr[2]);
433
328
  }
329
+ }
434
330
 
435
- if (property.length > 1 && out) {
436
- out = out[property[1]];
331
+ if (!____0.isFileExistsSync(path)) {
332
+ let arr = name.split('/');
333
+ if (arr.length > 1) {
334
+ ____0.apps.forEach((ap) => {
335
+ if (arr.length === 2 && ap.name == arr[0]) {
336
+ path = ____0.path.join(ap.path, 'site_files', ____0.path.extname(arr[1]).replace('.', ''), arr[1]);
337
+ } else if (arr.length === 2 && ap.name2 == arr[0]) {
338
+ path = ____0.path.join(ap.path, 'site_files', ____0.path.extname(arr[1]).replace('.', ''), arr[1]);
339
+ } else if (arr.length === 3 && ap.name == arr[0]) {
340
+ path = ____0.path.join(ap.path, 'site_files', ____0.path.extname(arr[2]).replace('.', ''), arr[1], arr[2]);
341
+ }
342
+ });
437
343
  }
344
+ }
345
+
346
+ if (!____0.isFileExistsSync(path)) {
347
+ ____0.log(path, 'PATH NOT EXISTS parser.getContent()');
348
+ return '';
349
+ }
438
350
 
439
- if (property.length > 2 && out) {
440
- out = out[property[2]];
351
+ if (name.endsWith('.content.html')) {
352
+ let txt = ____0.readFileSync(path);
353
+ return txt;
354
+ } else if (name.endsWith('.html')) {
355
+ let txt = ____0.readFileSync(path);
356
+ let $ = ____0.$.load(txt, null, false);
357
+ $ = renderHtml($);
358
+ if (hide) {
359
+ return ____0.hide($.html());
441
360
  }
361
+ return $.html();
362
+ } else if (name.endsWith('.js')) {
363
+ let txt = ____0.readFileSync(path);
364
+ txt = parser.js(txt);
365
+ if (hide) {
366
+ txt = ____0.hide(txt);
367
+ }
368
+ return txt;
369
+ } else if (name.endsWith('.css')) {
370
+ let txt = ____0.readFileSync(path);
371
+ txt = parser.css(txt);
372
+ return txt;
373
+ } else {
374
+ let txt = ____0.readFileSync(path);
375
+ if (hide) {
376
+ txt = ____0.hide(txt);
377
+ }
378
+ return txt;
379
+ }
380
+ }
442
381
 
443
- if (property.length > 3 && out) {
444
- out = out[property[3]];
382
+ function handleXList1($, el, data) {
383
+ let property = $(el).attr('x-list1').split('.');
384
+ $(el).removeAttr('x-list1');
385
+ let list = null;
386
+ let html2 = '';
387
+ if (property.length > 0) {
388
+ if (property[0] == '*') {
389
+ list = data;
390
+ } else {
391
+ list = data[property[0]];
445
392
  }
393
+ }
394
+ if (list && property.length > 1) {
395
+ list = list[property[1]];
396
+ }
397
+ if (list && property.length > 2) {
398
+ list = list[property[2]];
399
+ }
400
+ if (Array.isArray(list)) {
401
+ let matches = $.html(el).match(/##item1.*?##/g);
402
+ list.forEach((item, i) => {
403
+ $(el).attr('x-item1', i);
404
+ let _html = $.html(el);
405
+ if (matches) {
406
+ for (let i = 0; i < matches.length; i++) {
407
+ let p = matches[i].replace('##item1.', '').replace('##', '').split('.');
408
+ let v = null;
409
+ if (p.length > 0) {
410
+ if (p[0] == '*' || !p[0]) {
411
+ v = item;
412
+ } else {
413
+ v = item[p[0]];
414
+ }
415
+ }
416
+ if (p.length > 1 && v) {
417
+ v = v[p[1]];
418
+ }
419
+ if (p.length > 2 && v) {
420
+ v = v[p[2]];
421
+ }
422
+
423
+ _html = _html.replace(matches[i], v || '');
424
+ }
425
+ }
426
+ let $2 = ____0.$.load(_html);
427
+ $2('[x-show-item1]').each(function (i, elem) {
428
+ let property = $(elem).attr('x-show-item1').split('.');
429
+ let out = null;
430
+ if (property.length > 0) {
431
+ if (property.length > 0) {
432
+ out = item[property[0]];
433
+ }
434
+
435
+ if (property.length > 1 && out) {
436
+ out = out[property[1]];
437
+ }
438
+
439
+ if (property.length > 2 && out) {
440
+ out = out[property[2]];
441
+ }
442
+
443
+ if (property.length > 3 && out) {
444
+ out = out[property[3]];
445
+ }
446
+
447
+ if (property.length > 4 && out) {
448
+ out = out[property[4]];
449
+ }
450
+
451
+ if (property.length > 5 && out) {
452
+ out = out[property[5]];
453
+ }
454
+ }
455
+ if (!out) {
456
+ $(this).remove();
457
+ } else {
458
+ $(this).removeAttr('x-show-item1');
459
+ }
460
+ });
461
+ $2('[x-list2]').each(function (i2, elem2) {
462
+ $(handleXList2($2, elem2, item)).insertAfter($(this));
463
+ $(this).remove();
464
+ });
465
+ html2 += $2.html();
466
+ });
467
+ }
446
468
 
447
- if (property.length > 4 && out) {
448
- out = out[property[4]];
469
+ return html2;
470
+ }
471
+
472
+ function handleXList2($, el, data) {
473
+ let property = $(el).attr('x-list2').split('.');
474
+ $(el).removeAttr('x-list2');
475
+ let list = null;
476
+ let html2 = '';
477
+ if (property.length > 0) {
478
+ if (property[0] == '*') {
479
+ list = data;
480
+ } else {
481
+ list = data[property[0]];
449
482
  }
483
+ }
484
+ if (list && property.length > 1) {
485
+ list = list[property[1]];
486
+ }
487
+ if (Array.isArray(list)) {
488
+ let matches = $.html(el).match(/##item2.*?##/g);
489
+ list.forEach((item, i) => {
490
+ $(el).attr('x-item2', i);
491
+ let _html = $.html(el);
492
+ if (matches) {
493
+ for (let i = 0; i < matches.length; i++) {
494
+ let p = matches[i].replace('##item2.', '').replace('##', '').split('.');
495
+ let v = null;
496
+ if (p.length > 0) {
497
+ if (p[0] == '*' || !p[0]) {
498
+ v = item;
499
+ } else {
500
+ v = item[p[0]];
501
+ }
502
+ }
503
+ if (p.length > 1 && v) {
504
+ v = v[p[1]];
505
+ }
506
+ if (p.length > 2 && v) {
507
+ v = v[p[2]];
508
+ }
509
+ _html = _html.replace(matches[i], v || '');
510
+ }
511
+ }
512
+ let $2 = ____0.$.load(_html);
513
+ $2('[x-show-item2]').each(function (i, elem) {
514
+ let property = $(elem).attr('x-show-item2').split('.');
515
+ let out = null;
516
+ if (property.length > 0) {
517
+ if (property.length > 0) {
518
+ out = item[property[0]];
519
+ }
520
+
521
+ if (property.length > 1 && out) {
522
+ out = out[property[1]];
523
+ }
524
+
525
+ if (property.length > 2 && out) {
526
+ out = out[property[2]];
527
+ }
528
+
529
+ if (property.length > 3 && out) {
530
+ out = out[property[3]];
531
+ }
532
+
533
+ if (property.length > 4 && out) {
534
+ out = out[property[4]];
535
+ }
536
+
537
+ if (property.length > 5 && out) {
538
+ out = out[property[5]];
539
+ }
540
+ }
541
+ if (!out) {
542
+ $(this).remove();
543
+ } else {
544
+ $(this).removeAttr('x-show-item2');
545
+ }
546
+ });
547
+ html2 += $2.html();
548
+ });
549
+ }
550
+ return html2;
551
+ }
450
552
 
451
- if (property.length > 5 && out) {
452
- out = out[property[5]];
553
+ function renderHtml($, log) {
554
+ $('[x-setting]').each(function (i, elem) {
555
+ let property = $(elem).attr('x-setting').split('.');
556
+ let out = null;
557
+ if (property.length > 0) {
558
+ if (property.length > 0) {
559
+ out = ____0.setting[property[0]];
560
+ }
561
+
562
+ if (property.length > 1 && out) {
563
+ if (out) {
564
+ out = out[property[1]];
565
+ } else {
566
+ out = null;
567
+ }
568
+ }
569
+ if (property.length > 2 && out) {
570
+ if (out) {
571
+ out = out[property[2]];
572
+ } else {
573
+ out = null;
574
+ }
575
+ }
576
+ if (property.length > 3 && out) {
577
+ if (out) {
578
+ out = out[property[3]];
579
+ } else {
580
+ out = null;
581
+ }
582
+ }
583
+ if (property.length > 4 && out) {
584
+ if (out) {
585
+ out = out[property[4]];
586
+ } else {
587
+ out = null;
588
+ }
589
+ }
590
+ }
591
+ if (!out) {
592
+ $(this).remove();
593
+ } else {
594
+ $(this).removeAttr('x-setting');
453
595
  }
454
- }
455
- if (!out) {
456
- $(this).remove();
457
- } else {
458
- $(this).removeAttr('x-show-item1');
459
- }
460
- });
461
- $2('[x-list2]').each(function (i2, elem2) {
462
- $(handleXList2($2, elem2, item)).insertAfter($(this));
463
- $(this).remove();
464
596
  });
465
- html2 += $2.html();
466
- });
467
- }
468
597
 
469
- return html2;
470
- }
471
-
472
- function handleXList2($, el, data) {
473
- let property = $(el).attr('x-list2').split('.');
474
- $(el).removeAttr('x-list2');
475
- let list = null;
476
- let html2 = '';
477
- if (property.length > 0) {
478
- if (property[0] == '*') {
479
- list = data;
480
- } else {
481
- list = data[property[0]];
482
- }
483
- }
484
- if (list && property.length > 1) {
485
- list = list[property[1]];
486
- }
487
- if (Array.isArray(list)) {
488
- let matches = $.html(el).match(/##item2.*?##/g);
489
- list.forEach((item, i) => {
490
- $(el).attr('x-item2', i);
491
- let _html = $.html(el);
492
- if (matches) {
493
- for (let i = 0; i < matches.length; i++) {
494
- let p = matches[i].replace('##item2.', '').replace('##', '').split('.');
495
- let v = null;
496
- if (p.length > 0) {
497
- if (p[0] == '*' || !p[0]) {
498
- v = item;
499
- } else {
500
- v = item[p[0]];
501
- }
502
- }
503
- if (p.length > 1 && v) {
504
- v = v[p[1]];
505
- }
506
- if (p.length > 2 && v) {
507
- v = v[p[2]];
508
- }
509
- _html = _html.replace(matches[i], v || '');
510
- }
511
- }
512
- let $2 = ____0.$.load(_html);
513
- $2('[x-show-item2]').each(function (i, elem) {
514
- let property = $(elem).attr('x-show-item2').split('.');
515
- let out = null;
516
- if (property.length > 0) {
598
+ $('[x-data]').each(function (i, elem) {
599
+ let property = $(elem).attr('x-data').split('.');
600
+ let out = null;
517
601
  if (property.length > 0) {
518
- out = item[property[0]];
602
+ if (property.length > 0) {
603
+ out = req.data[property[0]];
604
+ }
605
+
606
+ if (property.length > 1 && out) {
607
+ if (out) {
608
+ out = out[property[1]];
609
+ } else {
610
+ out = null;
611
+ }
612
+ }
613
+ if (property.length > 2 && out) {
614
+ if (out) {
615
+ out = out[property[2]];
616
+ } else {
617
+ out = null;
618
+ }
619
+ }
620
+ if (property.length > 3 && out) {
621
+ if (out) {
622
+ out = out[property[3]];
623
+ } else {
624
+ out = null;
625
+ }
626
+ }
627
+ if (property.length > 4 && out) {
628
+ if (out) {
629
+ out = out[property[4]];
630
+ } else {
631
+ out = null;
632
+ }
633
+ }
519
634
  }
635
+ if (!out) {
636
+ $(this).remove();
637
+ } else {
638
+ $(this).removeAttr('x-data');
639
+ }
640
+ });
520
641
 
521
- if (property.length > 1 && out) {
522
- out = out[property[1]];
642
+ $('[x-permission]').each(function (i, elem) {
643
+ if (!____0.security.isUserHasPermission(req, res, $(this).attr('x-permission'))) {
644
+ $(this).remove();
645
+ } else {
646
+ $(this).removeAttr('x-permission');
523
647
  }
648
+ });
524
649
 
525
- if (property.length > 2 && out) {
526
- out = out[property[2]];
650
+ $('[x-role]').each(function (i, elem) {
651
+ if (!____0.security.isUserHasRole(req, res, $(this).attr('x-role'))) {
652
+ $(this).remove();
653
+ } else {
654
+ $(this).removeAttr('x-role');
527
655
  }
656
+ });
528
657
 
529
- if (property.length > 3 && out) {
530
- out = out[property[3]];
658
+ $('[x-permissions]').each(function (i, elem) {
659
+ if (!____0.security.isUserHasPermissions(req, res, $(this).attr('x-permissions'))) {
660
+ $(this).remove();
661
+ } else {
662
+ $(this).removeAttr('x-permissions');
531
663
  }
664
+ });
532
665
 
533
- if (property.length > 4 && out) {
534
- out = out[property[4]];
666
+ $('[x-roles]').each(function (i, elem) {
667
+ if (!____0.security.isUserHasRoles(req, res, $(this).attr('x-roles'))) {
668
+ $(this).remove();
669
+ } else {
670
+ $(this).removeAttr('x-roles');
535
671
  }
672
+ });
536
673
 
537
- if (property.length > 5 && out) {
538
- out = out[property[5]];
674
+ $('[x-lang]').each(function (i, elem) {
675
+ if ($(this).attr('x-lang') !== req.session.language.id) {
676
+ $(this).remove();
677
+ } else {
678
+ $(this).removeAttr('x-lang');
539
679
  }
540
- }
541
- if (!out) {
542
- $(this).remove();
543
- } else {
544
- $(this).removeAttr('x-show-item2');
545
- }
546
680
  });
547
- html2 += $2.html();
548
- });
549
- }
550
- return html2;
551
- }
552
-
553
- function renderHtml($, log) {
554
- $('[x-setting]').each(function (i, elem) {
555
- let property = $(elem).attr('x-setting').split('.');
556
- let out = null;
557
- if (property.length > 0) {
558
- if (property.length > 0) {
559
- out = ____0.setting[property[0]];
560
- }
561
-
562
- if (property.length > 1 && out) {
563
- if (out) {
564
- out = out[property[1]];
565
- } else {
566
- out = null;
567
- }
568
- }
569
- if (property.length > 2 && out) {
570
- if (out) {
571
- out = out[property[2]];
572
- } else {
573
- out = null;
574
- }
575
- }
576
- if (property.length > 3 && out) {
577
- if (out) {
578
- out = out[property[3]];
579
- } else {
580
- out = null;
581
- }
582
- }
583
- if (property.length > 4 && out) {
584
- if (out) {
585
- out = out[property[4]];
586
- } else {
587
- out = null;
588
- }
589
- }
590
- }
591
- if (!out) {
592
- $(this).remove();
593
- } else {
594
- $(this).removeAttr('x-setting');
595
- }
596
- });
597
-
598
- $('[x-data]').each(function (i, elem) {
599
- let property = $(elem).attr('x-data').split('.');
600
- let out = null;
601
- if (property.length > 0) {
602
- if (property.length > 0) {
603
- out = req.data[property[0]];
604
- }
605
-
606
- if (property.length > 1 && out) {
607
- if (out) {
608
- out = out[property[1]];
609
- } else {
610
- out = null;
611
- }
612
- }
613
- if (property.length > 2 && out) {
614
- if (out) {
615
- out = out[property[2]];
616
- } else {
617
- out = null;
618
- }
619
- }
620
- if (property.length > 3 && out) {
621
- if (out) {
622
- out = out[property[3]];
623
- } else {
624
- out = null;
625
- }
626
- }
627
- if (property.length > 4 && out) {
628
- if (out) {
629
- out = out[property[4]];
630
- } else {
631
- out = null;
632
- }
633
- }
634
- }
635
- if (!out) {
636
- $(this).remove();
637
- } else {
638
- $(this).removeAttr('x-data');
639
- }
640
- });
641
-
642
- $('[x-permission]').each(function (i, elem) {
643
- if (!____0.security.isUserHasPermission(req, res, $(this).attr('x-permission'))) {
644
- $(this).remove();
645
- } else {
646
- $(this).removeAttr('x-permission');
647
- }
648
- });
649
-
650
- $('[x-role]').each(function (i, elem) {
651
- if (!____0.security.isUserHasRole(req, res, $(this).attr('x-role'))) {
652
- $(this).remove();
653
- } else {
654
- $(this).removeAttr('x-role');
655
- }
656
- });
657
-
658
- $('[x-permissions]').each(function (i, elem) {
659
- if (!____0.security.isUserHasPermissions(req, res, $(this).attr('x-permissions'))) {
660
- $(this).remove();
661
- } else {
662
- $(this).removeAttr('x-permissions');
663
- }
664
- });
665
-
666
- $('[x-roles]').each(function (i, elem) {
667
- if (!____0.security.isUserHasRoles(req, res, $(this).attr('x-roles'))) {
668
- $(this).remove();
669
- } else {
670
- $(this).removeAttr('x-roles');
671
- }
672
- });
673
-
674
- $('[x-lang]').each(function (i, elem) {
675
- if ($(this).attr('x-lang') !== req.session.language.id) {
676
- $(this).remove();
677
- } else {
678
- $(this).removeAttr('x-lang');
679
- }
680
- });
681
-
682
- $('[x-feature]').each(function (i, elem) {
683
- let f = $(this).attr('x-feature');
684
- let not = !1;
685
- if (f.startsWith('!')) {
686
- f = f.replace('!', '');
687
- not = !0;
688
- }
689
- if (!req.features.some((ff) => ff.like(f)) && !not) {
690
- $(this).remove();
691
- } else if (req.features.some((ff) => ff.like(f)) && not) {
692
- $(this).remove();
693
- } else {
694
- $(this).removeAttr('x-feature');
695
- }
696
- });
697
-
698
- $('[x-features]').each(function (i, elem) {
699
- let fs = $(this).attr('x-features');
700
- if (fs.indexOf('||') > -1) {
701
- let del = !0;
702
- fs.split('||').forEach((f) => {
703
- f = f.trim();
704
- let not = !1;
705
- if (f.startsWith('!')) {
706
- f = f.replace('!', '');
707
- not = !0;
708
- }
709
- if (req.features.some((ff) => ff.like(f)) && !not) {
710
- del = !1;
711
- }
712
- if (!req.features.some((ff) => ff.like(f)) && not) {
713
- del = !1;
714
- }
681
+
682
+ $('[x-feature]').each(function (i, elem) {
683
+ let f = $(this).attr('x-feature');
684
+ let not = !1;
685
+ if (f.startsWith('!')) {
686
+ f = f.replace('!', '');
687
+ not = !0;
688
+ }
689
+ if (!req.features.some((ff) => ff.like(f)) && !not) {
690
+ $(this).remove();
691
+ } else if (req.features.some((ff) => ff.like(f)) && not) {
692
+ $(this).remove();
693
+ } else {
694
+ $(this).removeAttr('x-feature');
695
+ }
715
696
  });
716
697
 
717
- if (del) {
718
- $(this).remove();
719
- }
720
- } else if (fs.indexOf('&&') > -1) {
721
- let ok_list = [];
722
- fs.split('&&').forEach((f) => {
723
- f = f.trim();
724
- let d = !0;
725
- if (f.startsWith('!')) {
726
- f = f.replace('!', '');
727
- d = !1;
728
- }
729
- if (!req.features.some((ff) => ff.like(f)) && !d) {
730
- ok_list.push({});
731
- }
732
- if (req.features.some((ff) => ff.like(f)) && d) {
733
- ok_list.push({});
734
- }
698
+ $('[x-features]').each(function (i, elem) {
699
+ let fs = $(this).attr('x-features');
700
+ if (fs.indexOf('||') > -1) {
701
+ let del = !0;
702
+ fs.split('||').forEach((f) => {
703
+ f = f.trim();
704
+ let not = !1;
705
+ if (f.startsWith('!')) {
706
+ f = f.replace('!', '');
707
+ not = !0;
708
+ }
709
+ if (req.features.some((ff) => ff.like(f)) && !not) {
710
+ del = !1;
711
+ }
712
+ if (!req.features.some((ff) => ff.like(f)) && not) {
713
+ del = !1;
714
+ }
715
+ });
716
+
717
+ if (del) {
718
+ $(this).remove();
719
+ }
720
+ } else if (fs.indexOf('&&') > -1) {
721
+ let ok_list = [];
722
+ fs.split('&&').forEach((f) => {
723
+ f = f.trim();
724
+ let d = !0;
725
+ if (f.startsWith('!')) {
726
+ f = f.replace('!', '');
727
+ d = !1;
728
+ }
729
+ if (!req.features.some((ff) => ff.like(f)) && !d) {
730
+ ok_list.push({});
731
+ }
732
+ if (req.features.some((ff) => ff.like(f)) && d) {
733
+ ok_list.push({});
734
+ }
735
+ });
736
+ if (ok_list.length !== fs.split('&&').length) {
737
+ $(this).remove();
738
+ }
739
+ } else {
740
+ f = fs.trim();
741
+ let d = !0;
742
+ if (f.startsWith('!')) {
743
+ f = f.replace('!', '');
744
+ d = !1;
745
+ }
746
+ if (!req.features.some((ff) => ff.like(f)) && d) {
747
+ $(this).remove();
748
+ }
749
+ if (req.features.some((ff) => ff.like(f)) && !d) {
750
+ $(this).remove();
751
+ }
752
+ }
735
753
  });
736
- if (ok_list.length !== fs.split('&&').length) {
737
- $(this).remove();
738
- }
739
- } else {
740
- f = fs.trim();
741
- let d = !0;
742
- if (f.startsWith('!')) {
743
- f = f.replace('!', '');
744
- d = !1;
745
- }
746
- if (!req.features.some((ff) => ff.like(f)) && d) {
747
- $(this).remove();
754
+
755
+ if (route.parser.like('*css*')) {
756
+ $('style').each(function (i, elem) {
757
+ $(this).html(parser.css($(this).html()));
758
+ });
748
759
  }
749
- if (req.features.some((ff) => ff.like(f)) && !d) {
750
- $(this).remove();
760
+
761
+ if (route.parser.like('*js*')) {
762
+ $('script').each(function (i, elem) {
763
+ $(this).html(parser.js($(this).html()));
764
+ });
751
765
  }
752
- }
753
- });
754
766
 
755
- if (route.parser.like('*css*')) {
756
- $('style').each(function (i, elem) {
757
- $(this).html(parser.css($(this).html()));
758
- });
759
- }
767
+ $($('[x-import]').get().reverse()).each(function (i, elem) {
768
+ let file = $(this).attr('x-import');
769
+ if (file.endsWith('.html')) {
770
+ $(this).html(getContent(file) + $(this).html());
771
+ } else if (file.endsWith('.css')) {
772
+ $(this).text(getContent(file) + $(this).html());
773
+ } else {
774
+ $(this).text(getContent(file) + $(this).text());
775
+ }
776
+ $(this).removeAttr('x-import');
777
+ });
778
+
779
+ $($('[x-append]').get().reverse()).each(function (i, elem) {
780
+ let file = $(this).attr('x-append');
781
+ $(this).removeAttr('x-append');
782
+ if (file.endsWith('.html')) {
783
+ $(this).html($(this).html() + getContent(file));
784
+ } else if (file.endsWith('.css')) {
785
+ $(this).text($(this).html() + getContent(file));
786
+ } else {
787
+ $(this).text($(this).text() + getContent(file));
788
+ }
789
+ $(this).removeAttr('x-append');
790
+ });
791
+
792
+ $($('[x-replace]').get().reverse()).each(function (i, elem) {
793
+ let file = $(this).attr('x-replace');
794
+
795
+ $(getContent(file)).insertAfter($(this));
796
+ $(this).remove();
797
+
798
+ $(this).removeAttr('x-replace');
799
+ });
760
800
 
761
- if (route.parser.like('*js*')) {
762
- $('script').each(function (i, elem) {
763
- $(this).html(parser.js($(this).html()));
764
- });
801
+ $('[x-list1]').each(function (i, elem) {
802
+ $(handleXList1($, elem, req.data)).insertAfter($(this));
803
+ $(this).remove();
804
+ });
805
+ $('[x-list2]').each(function (i, elem) {
806
+ $(handleXList2($, elem, req.data)).insertAfter($(this));
807
+ $(this).remove();
808
+ });
809
+ return $;
765
810
  }
766
811
 
767
- $($('[x-import]').get().reverse()).each(function (i, elem) {
768
- let file = $(this).attr('x-import');
769
- if (file.endsWith('.html')) {
770
- $(this).html(getContent(file) + $(this).html());
771
- } else if (file.endsWith('.css')) {
772
- $(this).text(getContent(file) + $(this).html());
773
- } else {
774
- $(this).text(getContent(file) + $(this).text());
775
- }
776
- $(this).removeAttr('x-import');
777
- });
778
-
779
- $($('[x-append]').get().reverse()).each(function (i, elem) {
780
- let file = $(this).attr('x-append');
781
- $(this).removeAttr('x-append');
782
- if (file.endsWith('.html')) {
783
- $(this).html($(this).html() + getContent(file));
784
- } else if (file.endsWith('.css')) {
785
- $(this).text($(this).html() + getContent(file));
786
- } else {
787
- $(this).text($(this).text() + getContent(file));
788
- }
789
- $(this).removeAttr('x-append');
790
- });
791
-
792
- $($('[x-replace]').get().reverse()).each(function (i, elem) {
793
- let file = $(this).attr('x-replace');
794
-
795
- $(getContent(file)).insertAfter($(this));
796
- $(this).remove();
797
-
798
- $(this).removeAttr('x-replace');
799
- });
800
-
801
- $('[x-list1]').each(function (i, elem) {
802
- $(handleXList1($, elem, req.data)).insertAfter($(this));
803
- $(this).remove();
804
- });
805
- $('[x-list2]').each(function (i, elem) {
806
- $(handleXList2($, elem, req.data)).insertAfter($(this));
807
- $(this).remove();
808
- });
809
- return $;
810
- }
811
-
812
- parser.handleMatches = function (txt) {
813
- let matches = txt.match(/##.*?##/g);
814
- if (matches) {
815
- for (let i = 0; i < matches.length; i++) {
816
- let v = matches[i];
817
-
818
- if (v.startsWith('##var.')) {
819
- v = v.replace('##var.', '').replace('##', '');
820
- txt = txt.replace(matches[i], renderVar(v));
821
- } else if (v.startsWith('##word.')) {
822
- v = v.replace('##word.', '').replace('##', '');
823
- txt = txt.replace(matches[i], renderWord(v));
824
- } else if (v.startsWith('##user.')) {
825
- v = v.replace('##user.', '').replace('##', '');
826
- txt = txt.replace(matches[i], renderUser(v));
827
- } else if (v.startsWith('##site.')) {
828
- v = v.replace('##site.', '').replace('##', '');
829
- txt = txt.replace(matches[i], render_site(v));
830
- } else if (v.startsWith('##req.')) {
831
- v = v.replace('##req.', '').replace('##', '');
832
- txt = txt.replace(matches[i], renderRequest(v));
833
- } else if (v.startsWith('##session.')) {
834
- v = v.replace('##session.', '').replace('##', '');
835
- txt = txt.replace(matches[i], renderSession(v));
836
- } else if (v.startsWith('##json.')) {
837
- v = v.replace('##json.', '').replace('##', '');
838
- txt = txt.replace(matches[i], renderJson(v));
839
- } else if (v.startsWith('##setting.')) {
840
- v = v.replace('##setting.', '').replace('##', '');
841
- txt = txt.replace(matches[i], renderSetting(v));
842
- } else if (v.startsWith('##params.')) {
843
- v = v.replace('##params.', '').replace('##', '');
844
- txt = txt.replace(matches[i], renderParam(v));
845
- } else if (v.startsWith('##query.')) {
846
- v = v.replace('##query.', '').replace('##', '');
847
- txt = txt.replace(matches[i], renderQuery(v));
848
- } else if (v.startsWith('##data.')) {
849
- v = v.replace('##data.', '').replace('##', '');
850
- txt = txt.replace(matches[i], renderData(v));
851
- } else {
812
+ parser.handleMatches = function (txt) {
813
+ let matches = txt.match(/##.*?##/g);
814
+ let handled = false;
815
+ if (matches) {
816
+ for (let i = 0; i < matches.length; i++) {
817
+ let v = matches[i];
818
+
819
+ if (v.startsWith('##var.')) {
820
+ v = v.replace('##var.', '').replace('##', '');
821
+ txt = txt.replace(matches[i], renderVar(v));
822
+ handled = true;
823
+ } else if (v.startsWith('##user.')) {
824
+ v = v.replace('##user.', '').replace('##', '');
825
+ txt = txt.replace(matches[i], renderUser(v));
826
+ handled = true;
827
+ } else if (v.startsWith('##site.')) {
828
+ v = v.replace('##site.', '').replace('##', '');
829
+ txt = txt.replace(matches[i], render_site(v));
830
+ handled = true;
831
+ } else if (v.startsWith('##req.')) {
832
+ v = v.replace('##req.', '').replace('##', '');
833
+ txt = txt.replace(matches[i], renderRequest(v));
834
+ handled = true;
835
+ } else if (v.startsWith('##session.')) {
836
+ v = v.replace('##session.', '').replace('##', '');
837
+ txt = txt.replace(matches[i], renderSession(v));
838
+ handled = true;
839
+ } else if (v.startsWith('##json.')) {
840
+ v = v.replace('##json.', '').replace('##', '');
841
+ txt = txt.replace(matches[i], renderJson(v));
842
+ handled = true;
843
+ } else if (v.startsWith('##setting.')) {
844
+ v = v.replace('##setting.', '').replace('##', '');
845
+ txt = txt.replace(matches[i], renderSetting(v));
846
+ handled = true;
847
+ } else if (v.startsWith('##params.')) {
848
+ v = v.replace('##params.', '').replace('##', '');
849
+ txt = txt.replace(matches[i], renderParam(v));
850
+ handled = true;
851
+ } else if (v.startsWith('##query.')) {
852
+ v = v.replace('##query.', '').replace('##', '');
853
+ txt = txt.replace(matches[i], renderQuery(v));
854
+ handled = true;
855
+ } else if (v.startsWith('##data.')) {
856
+ v = v.replace('##data.', '').replace('##', '');
857
+ txt = txt.replace(matches[i], renderData(v));
858
+ handled = true;
859
+ } else if (v.startsWith('##word.')) {
860
+ v = v.replace('##word.', '').replace('##', '');
861
+ txt = txt.replace(matches[i], renderWord(v));
862
+ handled = true;
863
+ } else {
864
+ }
865
+ }
852
866
  }
853
- }
854
- }
855
- return txt;
856
- };
857
-
858
- parser.html = function (content) {
859
- let $ = ____0.$.load(content);
860
- $ = renderHtml($);
861
- txt = parser.handleMatches($.html());
862
- return txt;
863
- };
864
- parser.txt = function (content) {
865
- content = parser.handleMatches(content);
866
- return content;
867
- };
868
-
869
- parser.js = function (content) {
870
- let matches = content.match(/\/\*##.*?\*\//g);
871
- if (matches) {
872
- for (let i = 0; i < matches.length; i++) {
873
- let v = matches[i];
874
- v = v.replace('/*##', '').replace('*/', '');
875
- content = content.replace(matches[i], getContent(v));
876
- }
877
- }
878
- content = parser.handleMatches(content);
879
- return content;
880
- };
867
+ if (handled) {
868
+ txt = parser.handleMatches(txt);
869
+ }
870
+ return txt;
871
+ };
872
+
873
+ parser.html = function (content) {
874
+ let $ = ____0.$.load(content);
875
+ $ = renderHtml($);
876
+ txt = parser.handleMatches($.html());
877
+ return txt;
878
+ };
879
+ parser.txt = function (content) {
880
+ content = parser.handleMatches(content);
881
+ return content;
882
+ };
883
+
884
+ parser.js = function (content) {
885
+ let matches = content.match(/\/\*##.*?\*\//g);
886
+ if (matches) {
887
+ for (let i = 0; i < matches.length; i++) {
888
+ let v = matches[i];
889
+ v = v.replace('/*##', '').replace('*/', '');
890
+ content = content.replace(matches[i], getContent(v));
891
+ }
892
+ }
893
+ content = parser.handleMatches(content);
894
+ return content;
895
+ };
881
896
 
882
- parser.css = function (content) {
883
- content = parser.handleMatches(content);
897
+ parser.css = function (content) {
898
+ content = parser.handleMatches(content);
884
899
 
885
- let matches = content.match(/var\(---.*?\)/g);
886
- if (matches) {
887
- for (let i = 0; i < matches.length; i++) {
888
- let v = matches[i];
900
+ let matches = content.match(/var\(---.*?\)/g);
901
+ if (matches) {
902
+ for (let i = 0; i < matches.length; i++) {
903
+ let v = matches[i];
889
904
 
890
- v = v.replace('var(---', '').replace(')', '');
891
- content = content.replace(matches[i], renderVar(v));
892
- }
893
- }
905
+ v = v.replace('var(---', '').replace(')', '');
906
+ content = content.replace(matches[i], renderVar(v));
907
+ }
908
+ }
894
909
 
895
- let matches2 = content.match(/word\(---.*?\)/g);
896
- if (matches2) {
897
- for (let i = 0; i < matches2.length; i++) {
898
- let v = matches2[i];
910
+ let matches2 = content.match(/word\(---.*?\)/g);
911
+ if (matches2) {
912
+ for (let i = 0; i < matches2.length; i++) {
913
+ let v = matches2[i];
899
914
 
900
- v = v.replace('word(---', '').replace(')', '');
901
- content = content.replace(matches2[i], renderWord(v));
902
- }
903
- }
915
+ v = v.replace('word(---', '').replace(')', '');
916
+ content = content.replace(matches2[i], renderWord(v));
917
+ }
918
+ }
904
919
 
905
- return content;
906
- };
920
+ return content;
921
+ };
907
922
 
908
- parser.json = function (content) {
909
- return content;
910
- };
923
+ parser.json = function (content) {
924
+ return content;
925
+ };
911
926
 
912
- parser.renderHtml = renderHtml;
913
- return parser;
927
+ parser.renderHtml = renderHtml;
928
+ return parser;
914
929
  };