mirror of
https://github.com/cupcakearmy/cometa.git
synced 2025-03-12 14:27:28 +00:00
Dist Render
This commit is contained in:
parent
fcb136a708
commit
cbf94c1fb6
20
dist/actions.js
vendored
20
dist/actions.js
vendored
@ -84,7 +84,7 @@ exports.variables = (html, options, re) => {
|
|||||||
case 'object':
|
case 'object':
|
||||||
return JSON.stringify(output);
|
return JSON.stringify(output);
|
||||||
default:
|
default:
|
||||||
return output;
|
return String(output);
|
||||||
}
|
}
|
||||||
}],
|
}],
|
||||||
length: end + re.ending.length
|
length: end + re.ending.length
|
||||||
@ -102,9 +102,11 @@ exports.loop = (html, options, re) => {
|
|||||||
};
|
};
|
||||||
if (current.found === null || current.found.index !== 0)
|
if (current.found === null || current.found.index !== 0)
|
||||||
throw new Error(options_1.error.parse.default);
|
throw new Error(options_1.error.parse.default);
|
||||||
const statement = current.found[0].slice(re.begin.length + re.if.length, -re.ending.length).trim().split(re.for_in);
|
const statement = current.found[0]
|
||||||
current.variable = statement[0].trim();
|
.slice(re.begin.length + re.if.length, -re.ending.length).trim()
|
||||||
current.arr = statement[1].trim();
|
.split(new RegExp(` +${re.for_in} +`, 'g'));
|
||||||
|
current.variable = statement[0];
|
||||||
|
current.arr = statement[1];
|
||||||
let next;
|
let next;
|
||||||
do {
|
do {
|
||||||
next = {
|
next = {
|
||||||
@ -115,14 +117,20 @@ exports.loop = (html, options, re) => {
|
|||||||
throw new Error(options_1.error.parse.default);
|
throw new Error(options_1.error.parse.default);
|
||||||
} while (next.start !== null && next.start.index < next.end.index);
|
} while (next.start !== null && next.start.index < next.end.index);
|
||||||
html = html.substring(current.found[0].length, next.end.index);
|
html = html.substring(current.found[0].length, next.end.index);
|
||||||
|
const content = compiler_1.compileBlock(html, options, re);
|
||||||
return {
|
return {
|
||||||
parts: [(data) => {
|
parts: [(data) => {
|
||||||
|
const it = util_1.getFromObject(data, current.arr);
|
||||||
|
if (!(Symbol.iterator in Object(it)))
|
||||||
|
return '';
|
||||||
|
else {
|
||||||
let ret = '';
|
let ret = '';
|
||||||
for (const variable of util_1.getFromObject(data, current.arr)) {
|
for (const variable of it) {
|
||||||
const newData = Object.assign({ [current.variable]: variable }, data);
|
const newData = Object.assign({ [current.variable]: variable }, data);
|
||||||
ret += parser_1.computeParts(compiler_1.compileBlock(html, options, re).parts, newData);
|
ret += parser_1.computeParts(content.parts, newData);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
}],
|
}],
|
||||||
length: next.end.index + next.end[0].length
|
length: next.end.index + next.end[0].length
|
||||||
};
|
};
|
||||||
|
2
dist/options.js
vendored
2
dist/options.js
vendored
@ -31,5 +31,5 @@ exports.re = {
|
|||||||
for: '*',
|
for: '*',
|
||||||
for_in: 'in',
|
for_in: 'in',
|
||||||
closing_tag: '/',
|
closing_tag: '/',
|
||||||
valid_variable: '[A-z](\\w|\\.)*?',
|
valid_variable: '[A-z](\\w|\\.|\\[|\\])*?',
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user