2020-11-26 16:45:25 +01:00
|
|
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
|
|
|
|
|
|
|
|
exports[`t-set evaluate value expression 1`] = `
|
2022-05-26 15:09:09 +02:00
|
|
|
"function anonymous(app, bdom, helpers
|
2020-11-26 16:45:25 +01:00
|
|
|
) {
|
2022-06-08 11:09:39 +02:00
|
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
2021-12-01 17:03:53 +01:00
|
|
|
let { isBoundary, withDefault, setContextValue } = helpers;
|
2020-11-26 16:45:25 +01:00
|
|
|
|
|
|
|
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
|
|
|
|
|
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
|
|
|
ctx = Object.create(ctx);
|
2021-10-19 11:00:26 +02:00
|
|
|
ctx[isBoundary] = 1
|
|
|
|
|
setContextValue(ctx, \\"value\\", 1+2);
|
2021-12-22 11:33:12 +01:00
|
|
|
let txt1 = ctx['value'];
|
|
|
|
|
return block1([txt1]);
|
2020-11-26 16:45:25 +01:00
|
|
|
}
|
|
|
|
|
}"
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
exports[`t-set evaluate value expression, part 2 1`] = `
|
2022-05-26 15:09:09 +02:00
|
|
|
"function anonymous(app, bdom, helpers
|
2020-11-26 16:45:25 +01:00
|
|
|
) {
|
2022-06-08 11:09:39 +02:00
|
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
2021-12-01 17:03:53 +01:00
|
|
|
let { isBoundary, withDefault, setContextValue } = helpers;
|
2020-11-26 16:45:25 +01:00
|
|
|
|
|
|
|
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
|
|
|
|
|
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
|
|
|
ctx = Object.create(ctx);
|
2021-10-19 11:00:26 +02:00
|
|
|
ctx[isBoundary] = 1
|
|
|
|
|
setContextValue(ctx, \\"value\\", ctx['somevariable']+2);
|
2021-12-22 11:33:12 +01:00
|
|
|
let txt1 = ctx['value'];
|
|
|
|
|
return block1([txt1]);
|
2020-11-26 16:45:25 +01:00
|
|
|
}
|
|
|
|
|
}"
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
exports[`t-set set from attribute literal (no outside div) 1`] = `
|
2022-05-26 15:09:09 +02:00
|
|
|
"function anonymous(app, bdom, helpers
|
2020-11-26 16:45:25 +01:00
|
|
|
) {
|
2022-06-08 11:09:39 +02:00
|
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
2021-12-01 17:03:53 +01:00
|
|
|
let { isBoundary, withDefault, setContextValue } = helpers;
|
2020-11-26 16:45:25 +01:00
|
|
|
|
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
|
|
|
ctx = Object.create(ctx);
|
2021-10-19 11:00:26 +02:00
|
|
|
ctx[isBoundary] = 1
|
|
|
|
|
setContextValue(ctx, \\"value\\", 'ok');
|
2020-11-26 16:45:25 +01:00
|
|
|
return text(ctx['value']);
|
|
|
|
|
}
|
|
|
|
|
}"
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
exports[`t-set set from attribute literal 1`] = `
|
2022-05-26 15:09:09 +02:00
|
|
|
"function anonymous(app, bdom, helpers
|
2020-11-26 16:45:25 +01:00
|
|
|
) {
|
2022-06-08 11:09:39 +02:00
|
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
2021-12-01 17:03:53 +01:00
|
|
|
let { isBoundary, withDefault, setContextValue } = helpers;
|
2020-11-26 16:45:25 +01:00
|
|
|
|
|
|
|
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
|
|
|
|
|
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
|
|
|
ctx = Object.create(ctx);
|
2021-10-19 11:00:26 +02:00
|
|
|
ctx[isBoundary] = 1
|
|
|
|
|
setContextValue(ctx, \\"value\\", 'ok');
|
2021-12-22 11:33:12 +01:00
|
|
|
let txt1 = ctx['value'];
|
|
|
|
|
return block1([txt1]);
|
2020-11-26 16:45:25 +01:00
|
|
|
}
|
|
|
|
|
}"
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
exports[`t-set set from attribute lookup 1`] = `
|
2022-05-26 15:09:09 +02:00
|
|
|
"function anonymous(app, bdom, helpers
|
2020-11-26 16:45:25 +01:00
|
|
|
) {
|
2022-06-08 11:09:39 +02:00
|
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
2021-12-01 17:03:53 +01:00
|
|
|
let { isBoundary, withDefault, setContextValue } = helpers;
|
2020-11-26 16:45:25 +01:00
|
|
|
|
|
|
|
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
|
|
|
|
|
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
|
|
|
ctx = Object.create(ctx);
|
2021-10-19 11:00:26 +02:00
|
|
|
ctx[isBoundary] = 1
|
|
|
|
|
setContextValue(ctx, \\"stuff\\", ctx['value']);
|
2021-12-22 11:33:12 +01:00
|
|
|
let txt1 = ctx['stuff'];
|
|
|
|
|
return block1([txt1]);
|
2020-11-26 16:45:25 +01:00
|
|
|
}
|
|
|
|
|
}"
|
|
|
|
|
`;
|
|
|
|
|
|
2022-01-17 13:51:50 +01:00
|
|
|
exports[`t-set set from body literal (with t-if/t-else 1`] = `
|
2022-05-26 15:09:09 +02:00
|
|
|
"function anonymous(app, bdom, helpers
|
2022-01-17 13:51:50 +01:00
|
|
|
) {
|
2022-06-08 11:09:39 +02:00
|
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
2022-01-17 13:51:50 +01:00
|
|
|
let { isBoundary, withDefault, LazyValue } = helpers;
|
|
|
|
|
|
|
|
|
|
function value1(ctx, node, key = \\"\\") {
|
|
|
|
|
let b2,b3;
|
|
|
|
|
if (ctx['condition']) {
|
|
|
|
|
b2 = text(\`true\`);
|
|
|
|
|
} else {
|
|
|
|
|
b3 = text(\`false\`);
|
|
|
|
|
}
|
|
|
|
|
return multi([b2, b3]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
|
|
|
ctx = Object.create(ctx);
|
|
|
|
|
ctx[isBoundary] = 1
|
2022-06-22 15:39:31 +02:00
|
|
|
ctx[\`value\`] = new LazyValue(value1, ctx, this, node);
|
2022-01-17 13:51:50 +01:00
|
|
|
return text(ctx['value']);
|
|
|
|
|
}
|
|
|
|
|
}"
|
|
|
|
|
`;
|
|
|
|
|
|
2020-11-26 16:45:25 +01:00
|
|
|
exports[`t-set set from body literal 1`] = `
|
2022-05-26 15:09:09 +02:00
|
|
|
"function anonymous(app, bdom, helpers
|
2020-11-26 16:45:25 +01:00
|
|
|
) {
|
2022-06-08 11:09:39 +02:00
|
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
2021-12-01 17:03:53 +01:00
|
|
|
let { isBoundary, withDefault, setContextValue } = helpers;
|
2020-11-26 16:45:25 +01:00
|
|
|
|
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
|
|
|
ctx = Object.create(ctx);
|
2021-10-19 11:00:26 +02:00
|
|
|
ctx[isBoundary] = 1
|
|
|
|
|
setContextValue(ctx, \\"value\\", \`ok\`);
|
2020-11-26 16:45:25 +01:00
|
|
|
return text(ctx['value']);
|
|
|
|
|
}
|
|
|
|
|
}"
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
exports[`t-set set from body lookup 1`] = `
|
2022-05-26 15:09:09 +02:00
|
|
|
"function anonymous(app, bdom, helpers
|
2020-11-26 16:45:25 +01:00
|
|
|
) {
|
2022-06-08 11:09:39 +02:00
|
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
2021-12-22 15:06:28 +01:00
|
|
|
let { isBoundary, withDefault, LazyValue } = helpers;
|
2020-11-26 16:45:25 +01:00
|
|
|
|
|
|
|
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
|
|
|
|
|
2021-12-22 15:06:28 +01:00
|
|
|
function value1(ctx, node, key = \\"\\") {
|
|
|
|
|
return text(ctx['value']);
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-26 16:45:25 +01:00
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
|
|
|
ctx = Object.create(ctx);
|
2021-10-19 11:00:26 +02:00
|
|
|
ctx[isBoundary] = 1
|
2022-06-22 15:39:31 +02:00
|
|
|
ctx[\`stuff\`] = new LazyValue(value1, ctx, this, node);
|
2021-12-22 11:33:12 +01:00
|
|
|
let txt1 = ctx['stuff'];
|
|
|
|
|
return block1([txt1]);
|
2020-11-26 16:45:25 +01:00
|
|
|
}
|
|
|
|
|
}"
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
exports[`t-set set from empty body 1`] = `
|
2022-05-26 15:09:09 +02:00
|
|
|
"function anonymous(app, bdom, helpers
|
2020-11-26 16:45:25 +01:00
|
|
|
) {
|
2022-06-08 11:09:39 +02:00
|
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
2021-12-01 17:03:53 +01:00
|
|
|
let { isBoundary, withDefault, setContextValue } = helpers;
|
2020-11-26 16:45:25 +01:00
|
|
|
|
|
|
|
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
|
|
|
|
|
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
|
|
|
ctx = Object.create(ctx);
|
2021-10-19 11:00:26 +02:00
|
|
|
ctx[isBoundary] = 1
|
|
|
|
|
setContextValue(ctx, \\"stuff\\", null);
|
2021-12-22 11:33:12 +01:00
|
|
|
let txt1 = ctx['stuff'];
|
|
|
|
|
return block1([txt1]);
|
2020-11-26 16:45:25 +01:00
|
|
|
}
|
|
|
|
|
}"
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
exports[`t-set t-set and t-if 1`] = `
|
2022-05-26 15:09:09 +02:00
|
|
|
"function anonymous(app, bdom, helpers
|
2020-11-26 16:45:25 +01:00
|
|
|
) {
|
2022-06-08 11:09:39 +02:00
|
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
2021-12-01 17:03:53 +01:00
|
|
|
let { isBoundary, withDefault, setContextValue } = helpers;
|
2020-11-26 16:45:25 +01:00
|
|
|
|
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
|
|
|
|
|
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
|
|
|
ctx = Object.create(ctx);
|
2021-10-19 11:00:26 +02:00
|
|
|
ctx[isBoundary] = 1
|
2020-11-26 16:45:25 +01:00
|
|
|
let b2;
|
2021-10-19 11:00:26 +02:00
|
|
|
setContextValue(ctx, \\"v\\", ctx['value']);
|
2020-11-26 16:45:25 +01:00
|
|
|
if (ctx['v']==='ok') {
|
|
|
|
|
b2 = text(\`grimbergen\`);
|
|
|
|
|
}
|
|
|
|
|
return block1([], [b2]);
|
|
|
|
|
}
|
|
|
|
|
}"
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
exports[`t-set t-set body is evaluated immediately 1`] = `
|
2022-05-26 15:09:09 +02:00
|
|
|
"function anonymous(app, bdom, helpers
|
2020-11-26 16:45:25 +01:00
|
|
|
) {
|
2022-06-08 11:09:39 +02:00
|
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
2021-12-22 15:06:28 +01:00
|
|
|
let { isBoundary, withDefault, setContextValue, LazyValue, safeOutput } = helpers;
|
2020-11-26 16:45:25 +01:00
|
|
|
|
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
|
|
|
|
let block2 = createBlock(\`<span><block-text-0/></span>\`);
|
|
|
|
|
|
2021-12-22 15:06:28 +01:00
|
|
|
function value1(ctx, node, key = \\"\\") {
|
|
|
|
|
let txt1 = ctx['v1'];
|
|
|
|
|
return block2([txt1]);
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-26 16:45:25 +01:00
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
|
|
|
ctx = Object.create(ctx);
|
2021-10-19 11:00:26 +02:00
|
|
|
ctx[isBoundary] = 1
|
|
|
|
|
setContextValue(ctx, \\"v1\\", 'before');
|
2022-06-22 15:39:31 +02:00
|
|
|
ctx[\`v2\`] = new LazyValue(value1, ctx, this, node);
|
2021-10-19 11:00:26 +02:00
|
|
|
setContextValue(ctx, \\"v1\\", 'after');
|
2022-03-06 10:27:07 +01:00
|
|
|
const b3 = safeOutput(ctx['v2']);
|
2020-11-26 16:45:25 +01:00
|
|
|
return block1([], [b3]);
|
|
|
|
|
}
|
|
|
|
|
}"
|
|
|
|
|
`;
|
|
|
|
|
|
2021-10-19 11:00:26 +02:00
|
|
|
exports[`t-set t-set can't alter from within callee 1`] = `
|
2022-05-26 15:09:09 +02:00
|
|
|
"function anonymous(app, bdom, helpers
|
2021-10-19 11:00:26 +02:00
|
|
|
) {
|
2022-06-08 11:09:39 +02:00
|
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
2022-05-26 15:09:09 +02:00
|
|
|
let { isBoundary, withDefault, setContextValue } = helpers;
|
|
|
|
|
const callTemplate_1 = app.getTemplate(\`sub\`);
|
2021-10-19 11:00:26 +02:00
|
|
|
|
|
|
|
|
let block1 = createBlock(\`<div><p><block-text-0/></p><block-child-0/><p><block-text-1/></p></div>\`);
|
|
|
|
|
|
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
|
|
|
ctx = Object.create(ctx);
|
|
|
|
|
ctx[isBoundary] = 1
|
|
|
|
|
setContextValue(ctx, \\"iter\\", 'source');
|
2021-12-22 11:33:12 +01:00
|
|
|
let txt1 = ctx['iter'];
|
2022-03-06 10:27:07 +01:00
|
|
|
const b2 = callTemplate_1.call(this, ctx, node, key + \`__1\`);
|
2021-12-22 11:33:12 +01:00
|
|
|
let txt2 = ctx['iter'];
|
|
|
|
|
return block1([txt1, txt2], [b2]);
|
2021-10-19 11:00:26 +02:00
|
|
|
}
|
|
|
|
|
}"
|
|
|
|
|
`;
|
|
|
|
|
|
2021-12-20 11:19:59 +01:00
|
|
|
exports[`t-set t-set can't alter from within callee 2`] = `
|
2022-05-26 15:09:09 +02:00
|
|
|
"function anonymous(app, bdom, helpers
|
2021-10-19 11:00:26 +02:00
|
|
|
) {
|
2022-06-08 11:09:39 +02:00
|
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
2021-12-01 17:03:53 +01:00
|
|
|
let { isBoundary, withDefault, setContextValue } = helpers;
|
2021-10-19 11:00:26 +02:00
|
|
|
|
|
|
|
|
let block1 = createBlock(\`<div><block-text-0/><block-text-1/></div>\`);
|
|
|
|
|
|
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
|
|
|
ctx = Object.create(ctx);
|
|
|
|
|
ctx[isBoundary] = 1
|
2021-12-22 11:33:12 +01:00
|
|
|
let txt1 = ctx['iter'];
|
2021-10-19 11:00:26 +02:00
|
|
|
setContextValue(ctx, \\"iter\\", 'called');
|
2021-12-22 11:33:12 +01:00
|
|
|
let txt2 = ctx['iter'];
|
|
|
|
|
return block1([txt1, txt2]);
|
2021-10-19 11:00:26 +02:00
|
|
|
}
|
|
|
|
|
}"
|
|
|
|
|
`;
|
|
|
|
|
|
2021-12-20 11:19:59 +01:00
|
|
|
exports[`t-set t-set can't alter in t-call body 1`] = `
|
2022-05-26 15:09:09 +02:00
|
|
|
"function anonymous(app, bdom, helpers
|
2021-10-19 11:00:26 +02:00
|
|
|
) {
|
2022-06-08 11:09:39 +02:00
|
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
2022-05-26 15:09:09 +02:00
|
|
|
let { isBoundary, withDefault, setContextValue } = helpers;
|
|
|
|
|
const callTemplate_1 = app.getTemplate(\`sub\`);
|
2021-10-19 11:00:26 +02:00
|
|
|
|
|
|
|
|
let block1 = createBlock(\`<div><p><block-text-0/></p><block-child-0/><p><block-text-1/></p></div>\`);
|
|
|
|
|
|
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
|
|
|
ctx = Object.create(ctx);
|
|
|
|
|
ctx[isBoundary] = 1
|
|
|
|
|
setContextValue(ctx, \\"iter\\", 'source');
|
2021-12-22 11:33:12 +01:00
|
|
|
let txt1 = ctx['iter'];
|
2021-10-19 11:00:26 +02:00
|
|
|
ctx = Object.create(ctx);
|
|
|
|
|
ctx[isBoundary] = 1;
|
|
|
|
|
setContextValue(ctx, \\"iter\\", 'inCall');
|
2022-03-06 10:27:07 +01:00
|
|
|
const b2 = callTemplate_1.call(this, ctx, node, key + \`__1\`);
|
2021-10-19 11:00:26 +02:00
|
|
|
ctx = ctx.__proto__;
|
2021-12-22 11:33:12 +01:00
|
|
|
let txt2 = ctx['iter'];
|
|
|
|
|
return block1([txt1, txt2], [b2]);
|
2021-10-19 11:00:26 +02:00
|
|
|
}
|
|
|
|
|
}"
|
|
|
|
|
`;
|
|
|
|
|
|
2021-12-20 11:19:59 +01:00
|
|
|
exports[`t-set t-set can't alter in t-call body 2`] = `
|
2022-05-26 15:09:09 +02:00
|
|
|
"function anonymous(app, bdom, helpers
|
2021-12-20 11:19:59 +01:00
|
|
|
) {
|
2022-06-08 11:09:39 +02:00
|
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
2021-12-20 11:19:59 +01:00
|
|
|
let { isBoundary, withDefault, setContextValue } = helpers;
|
|
|
|
|
|
|
|
|
|
let block1 = createBlock(\`<div><block-text-0/><block-text-1/></div>\`);
|
|
|
|
|
|
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
|
|
|
ctx = Object.create(ctx);
|
|
|
|
|
ctx[isBoundary] = 1
|
2021-12-22 11:33:12 +01:00
|
|
|
let txt1 = ctx['iter'];
|
2021-12-20 11:19:59 +01:00
|
|
|
setContextValue(ctx, \\"iter\\", 'called');
|
2021-12-22 11:33:12 +01:00
|
|
|
let txt2 = ctx['iter'];
|
|
|
|
|
return block1([txt1, txt2]);
|
2021-12-20 11:19:59 +01:00
|
|
|
}
|
|
|
|
|
}"
|
|
|
|
|
`;
|
|
|
|
|
|
2021-10-19 11:00:26 +02:00
|
|
|
exports[`t-set t-set does not modify render context existing key values 1`] = `
|
2022-05-26 15:09:09 +02:00
|
|
|
"function anonymous(app, bdom, helpers
|
2021-10-19 11:00:26 +02:00
|
|
|
) {
|
2022-06-08 11:09:39 +02:00
|
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
2021-12-01 17:03:53 +01:00
|
|
|
let { isBoundary, withDefault, setContextValue } = helpers;
|
2021-10-19 11:00:26 +02:00
|
|
|
|
|
|
|
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
|
|
|
|
|
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
|
|
|
ctx = Object.create(ctx);
|
|
|
|
|
ctx[isBoundary] = 1
|
|
|
|
|
setContextValue(ctx, \\"value\\", 35);
|
2021-12-22 11:33:12 +01:00
|
|
|
let txt1 = ctx['value'];
|
|
|
|
|
return block1([txt1]);
|
2021-10-19 11:00:26 +02:00
|
|
|
}
|
|
|
|
|
}"
|
|
|
|
|
`;
|
|
|
|
|
|
2020-11-26 16:45:25 +01:00
|
|
|
exports[`t-set t-set evaluates an expression only once 1`] = `
|
2022-05-26 15:09:09 +02:00
|
|
|
"function anonymous(app, bdom, helpers
|
2020-11-26 16:45:25 +01:00
|
|
|
) {
|
2022-06-08 11:09:39 +02:00
|
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
2021-12-01 17:03:53 +01:00
|
|
|
let { isBoundary, withDefault, setContextValue } = helpers;
|
2020-11-26 16:45:25 +01:00
|
|
|
|
|
|
|
|
let block1 = createBlock(\`<div><block-text-0/><block-text-1/></div>\`);
|
|
|
|
|
|
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
|
|
|
ctx = Object.create(ctx);
|
2021-10-19 11:00:26 +02:00
|
|
|
ctx[isBoundary] = 1
|
|
|
|
|
setContextValue(ctx, \\"v\\", ctx['value']+' artois');
|
2021-12-22 11:33:12 +01:00
|
|
|
let txt1 = ctx['v'];
|
|
|
|
|
let txt2 = ctx['v'];
|
|
|
|
|
return block1([txt1, txt2]);
|
2020-11-26 16:45:25 +01:00
|
|
|
}
|
|
|
|
|
}"
|
|
|
|
|
`;
|
|
|
|
|
|
2021-10-19 11:00:26 +02:00
|
|
|
exports[`t-set t-set outside modified in t-foreach 1`] = `
|
2022-05-26 15:09:09 +02:00
|
|
|
"function anonymous(app, bdom, helpers
|
2021-10-19 11:00:26 +02:00
|
|
|
) {
|
2022-06-08 11:09:39 +02:00
|
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
2021-12-01 17:03:53 +01:00
|
|
|
let { isBoundary, withDefault, setContextValue, prepareList, withKey } = helpers;
|
2021-10-19 11:00:26 +02:00
|
|
|
|
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/><p>EndLoop: <block-text-0/></p></div>\`);
|
|
|
|
|
let block3 = createBlock(\`<p>InLoop: <block-text-0/></p>\`);
|
|
|
|
|
|
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
|
|
|
ctx = Object.create(ctx);
|
|
|
|
|
ctx[isBoundary] = 1
|
|
|
|
|
setContextValue(ctx, \\"iter\\", 0);
|
|
|
|
|
ctx = Object.create(ctx);
|
2022-03-06 10:27:07 +01:00
|
|
|
const [k_block2, v_block2, l_block2, c_block2] = prepareList(['a','b']);;
|
2021-10-19 11:00:26 +02:00
|
|
|
for (let i1 = 0; i1 < l_block2; i1++) {
|
|
|
|
|
ctx[\`val\`] = v_block2[i1];
|
2022-03-06 10:27:07 +01:00
|
|
|
const key1 = ctx['val'];
|
2021-12-22 11:33:12 +01:00
|
|
|
let txt1 = ctx['iter'];
|
|
|
|
|
c_block2[i1] = withKey(block3([txt1]), key1);
|
2021-10-19 11:00:26 +02:00
|
|
|
setContextValue(ctx, \\"iter\\", ctx['iter']+1);
|
|
|
|
|
}
|
|
|
|
|
ctx = ctx.__proto__;
|
2022-03-06 10:27:07 +01:00
|
|
|
const b2 = list(c_block2);
|
2021-12-22 11:33:12 +01:00
|
|
|
let txt2 = ctx['iter'];
|
|
|
|
|
return block1([txt2], [b2]);
|
2021-10-19 11:00:26 +02:00
|
|
|
}
|
|
|
|
|
}"
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
exports[`t-set t-set outside modified in t-foreach increment-after operator 1`] = `
|
2022-05-26 15:09:09 +02:00
|
|
|
"function anonymous(app, bdom, helpers
|
2021-10-19 11:00:26 +02:00
|
|
|
) {
|
2022-06-08 11:09:39 +02:00
|
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
2021-12-01 17:03:53 +01:00
|
|
|
let { isBoundary, withDefault, setContextValue, prepareList, withKey } = helpers;
|
2021-10-19 11:00:26 +02:00
|
|
|
|
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/><p>EndLoop: <block-text-0/></p></div>\`);
|
|
|
|
|
let block3 = createBlock(\`<p>InLoop: <block-text-0/></p>\`);
|
|
|
|
|
|
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
|
|
|
ctx = Object.create(ctx);
|
|
|
|
|
ctx[isBoundary] = 1
|
|
|
|
|
setContextValue(ctx, \\"iter\\", 0);
|
|
|
|
|
ctx = Object.create(ctx);
|
2022-03-06 10:27:07 +01:00
|
|
|
const [k_block2, v_block2, l_block2, c_block2] = prepareList(['a','b']);;
|
2021-10-19 11:00:26 +02:00
|
|
|
for (let i1 = 0; i1 < l_block2; i1++) {
|
|
|
|
|
ctx[\`val\`] = v_block2[i1];
|
2022-03-06 10:27:07 +01:00
|
|
|
const key1 = ctx['val'];
|
2021-12-22 11:33:12 +01:00
|
|
|
let txt1 = ctx['iter'];
|
|
|
|
|
c_block2[i1] = withKey(block3([txt1]), key1);
|
2021-10-19 11:00:26 +02:00
|
|
|
setContextValue(ctx, \\"iter\\", ctx['iter']++);
|
|
|
|
|
}
|
|
|
|
|
ctx = ctx.__proto__;
|
2022-03-06 10:27:07 +01:00
|
|
|
const b2 = list(c_block2);
|
2021-12-22 11:33:12 +01:00
|
|
|
let txt2 = ctx['iter'];
|
|
|
|
|
return block1([txt2], [b2]);
|
2021-10-19 11:00:26 +02:00
|
|
|
}
|
|
|
|
|
}"
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
exports[`t-set t-set outside modified in t-foreach increment-before operator 1`] = `
|
2022-05-26 15:09:09 +02:00
|
|
|
"function anonymous(app, bdom, helpers
|
2021-10-19 11:00:26 +02:00
|
|
|
) {
|
2022-06-08 11:09:39 +02:00
|
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
2021-12-01 17:03:53 +01:00
|
|
|
let { isBoundary, withDefault, setContextValue, prepareList, withKey } = helpers;
|
2021-10-19 11:00:26 +02:00
|
|
|
|
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/><p>EndLoop: <block-text-0/></p></div>\`);
|
|
|
|
|
let block3 = createBlock(\`<p>InLoop: <block-text-0/></p>\`);
|
|
|
|
|
|
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
|
|
|
ctx = Object.create(ctx);
|
|
|
|
|
ctx[isBoundary] = 1
|
|
|
|
|
setContextValue(ctx, \\"iter\\", 0);
|
|
|
|
|
ctx = Object.create(ctx);
|
2022-03-06 10:27:07 +01:00
|
|
|
const [k_block2, v_block2, l_block2, c_block2] = prepareList(['a','b']);;
|
2021-10-19 11:00:26 +02:00
|
|
|
for (let i1 = 0; i1 < l_block2; i1++) {
|
|
|
|
|
ctx[\`val\`] = v_block2[i1];
|
2022-03-06 10:27:07 +01:00
|
|
|
const key1 = ctx['val'];
|
2021-12-22 11:33:12 +01:00
|
|
|
let txt1 = ctx['iter'];
|
|
|
|
|
c_block2[i1] = withKey(block3([txt1]), key1);
|
2021-10-19 11:00:26 +02:00
|
|
|
setContextValue(ctx, \\"iter\\", ++ctx['iter']);
|
|
|
|
|
}
|
|
|
|
|
ctx = ctx.__proto__;
|
2022-03-06 10:27:07 +01:00
|
|
|
const b2 = list(c_block2);
|
2021-12-22 11:33:12 +01:00
|
|
|
let txt2 = ctx['iter'];
|
|
|
|
|
return block1([txt2], [b2]);
|
2021-10-19 11:00:26 +02:00
|
|
|
}
|
|
|
|
|
}"
|
|
|
|
|
`;
|
|
|
|
|
|
2020-11-26 16:45:25 +01:00
|
|
|
exports[`t-set t-set should reuse variable if possible 1`] = `
|
2022-05-26 15:09:09 +02:00
|
|
|
"function anonymous(app, bdom, helpers
|
2020-11-26 16:45:25 +01:00
|
|
|
) {
|
2022-06-08 11:09:39 +02:00
|
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
2021-12-01 17:03:53 +01:00
|
|
|
let { isBoundary, withDefault, setContextValue, prepareList, withKey } = helpers;
|
2020-11-26 16:45:25 +01:00
|
|
|
|
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
|
|
|
|
let block3 = createBlock(\`<div><span>v<block-text-0/></span></div>\`);
|
|
|
|
|
|
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
|
|
|
ctx = Object.create(ctx);
|
2021-10-19 11:00:26 +02:00
|
|
|
ctx[isBoundary] = 1
|
|
|
|
|
setContextValue(ctx, \\"v\\", 1);
|
2020-11-26 16:45:25 +01:00
|
|
|
ctx = Object.create(ctx);
|
2022-03-06 10:27:07 +01:00
|
|
|
const [k_block2, v_block2, l_block2, c_block2] = prepareList(ctx['list']);;
|
2021-10-15 13:08:07 +02:00
|
|
|
for (let i1 = 0; i1 < l_block2; i1++) {
|
|
|
|
|
ctx[\`elem\`] = v_block2[i1];
|
2020-11-26 16:45:25 +01:00
|
|
|
ctx[\`elem_index\`] = i1;
|
2022-03-06 10:27:07 +01:00
|
|
|
const key1 = ctx['elem_index'];
|
2021-12-22 11:33:12 +01:00
|
|
|
let txt1 = ctx['v'];
|
2021-10-19 11:00:26 +02:00
|
|
|
setContextValue(ctx, \\"v\\", ctx['elem']);
|
2021-12-22 11:33:12 +01:00
|
|
|
c_block2[i1] = withKey(block3([txt1]), key1);
|
2020-11-26 16:45:25 +01:00
|
|
|
}
|
2022-03-06 10:27:07 +01:00
|
|
|
const b2 = list(c_block2);
|
2020-11-26 16:45:25 +01:00
|
|
|
return block1([], [b2]);
|
|
|
|
|
}
|
|
|
|
|
}"
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
exports[`t-set t-set with content and sub t-esc 1`] = `
|
2022-05-26 15:09:09 +02:00
|
|
|
"function anonymous(app, bdom, helpers
|
2020-11-26 16:45:25 +01:00
|
|
|
) {
|
2022-06-08 11:09:39 +02:00
|
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
2021-12-22 15:06:28 +01:00
|
|
|
let { isBoundary, withDefault, LazyValue } = helpers;
|
2020-11-26 16:45:25 +01:00
|
|
|
|
|
|
|
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
|
|
|
|
|
2021-12-22 15:06:28 +01:00
|
|
|
function value1(ctx, node, key = \\"\\") {
|
2022-03-06 10:27:07 +01:00
|
|
|
const b3 = text(ctx['beep']);
|
|
|
|
|
const b4 = text(\` boop\`);
|
2021-12-22 15:06:28 +01:00
|
|
|
return multi([b3, b4]);
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-26 16:45:25 +01:00
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
|
|
|
ctx = Object.create(ctx);
|
2021-10-19 11:00:26 +02:00
|
|
|
ctx[isBoundary] = 1
|
2022-06-22 15:39:31 +02:00
|
|
|
ctx[\`setvar\`] = new LazyValue(value1, ctx, this, node);
|
2021-12-22 11:33:12 +01:00
|
|
|
let txt1 = ctx['setvar'];
|
|
|
|
|
return block1([txt1]);
|
2020-11-26 16:45:25 +01:00
|
|
|
}
|
|
|
|
|
}"
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
exports[`t-set t-set with t-value (falsy) and body 1`] = `
|
2022-05-26 15:09:09 +02:00
|
|
|
"function anonymous(app, bdom, helpers
|
2020-11-26 16:45:25 +01:00
|
|
|
) {
|
2022-06-08 11:09:39 +02:00
|
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
2021-12-22 15:06:28 +01:00
|
|
|
let { isBoundary, withDefault, setContextValue, LazyValue, safeOutput } = helpers;
|
2020-11-26 16:45:25 +01:00
|
|
|
|
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
|
|
|
|
let block2 = createBlock(\`<span><block-text-0/></span>\`);
|
|
|
|
|
|
2021-12-22 15:06:28 +01:00
|
|
|
function value1(ctx, node, key = \\"\\") {
|
|
|
|
|
let txt1 = ctx['v1'];
|
|
|
|
|
return block2([txt1]);
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-26 16:45:25 +01:00
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
|
|
|
ctx = Object.create(ctx);
|
2021-10-19 11:00:26 +02:00
|
|
|
ctx[isBoundary] = 1
|
|
|
|
|
setContextValue(ctx, \\"v3\\", false);
|
|
|
|
|
setContextValue(ctx, \\"v1\\", 'before');
|
2022-06-22 15:39:31 +02:00
|
|
|
ctx[\`v2\`] = withDefault(ctx['v3'], new LazyValue(value1, ctx, this, node));
|
2021-10-19 11:00:26 +02:00
|
|
|
setContextValue(ctx, \\"v1\\", 'after');
|
|
|
|
|
setContextValue(ctx, \\"v3\\", true);
|
2022-03-06 10:27:07 +01:00
|
|
|
const b3 = safeOutput(ctx['v2']);
|
2020-11-26 16:45:25 +01:00
|
|
|
return block1([], [b3]);
|
|
|
|
|
}
|
|
|
|
|
}"
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
exports[`t-set t-set with t-value (truthy) and body 1`] = `
|
2022-05-26 15:09:09 +02:00
|
|
|
"function anonymous(app, bdom, helpers
|
2020-11-26 16:45:25 +01:00
|
|
|
) {
|
2022-06-08 11:09:39 +02:00
|
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
2021-12-22 15:06:28 +01:00
|
|
|
let { isBoundary, withDefault, setContextValue, LazyValue, safeOutput } = helpers;
|
2020-11-26 16:45:25 +01:00
|
|
|
|
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
|
|
|
|
let block2 = createBlock(\`<span><block-text-0/></span>\`);
|
|
|
|
|
|
2021-12-22 15:06:28 +01:00
|
|
|
function value1(ctx, node, key = \\"\\") {
|
|
|
|
|
let txt1 = ctx['v1'];
|
|
|
|
|
return block2([txt1]);
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-26 16:45:25 +01:00
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
|
|
|
ctx = Object.create(ctx);
|
2021-10-19 11:00:26 +02:00
|
|
|
ctx[isBoundary] = 1
|
|
|
|
|
setContextValue(ctx, \\"v3\\", 'Truthy');
|
|
|
|
|
setContextValue(ctx, \\"v1\\", 'before');
|
2022-06-22 15:39:31 +02:00
|
|
|
ctx[\`v2\`] = withDefault(ctx['v3'], new LazyValue(value1, ctx, this, node));
|
2021-10-19 11:00:26 +02:00
|
|
|
setContextValue(ctx, \\"v1\\", 'after');
|
|
|
|
|
setContextValue(ctx, \\"v3\\", false);
|
2022-03-06 10:27:07 +01:00
|
|
|
const b3 = safeOutput(ctx['v2']);
|
2020-11-26 16:45:25 +01:00
|
|
|
return block1([], [b3]);
|
|
|
|
|
}
|
|
|
|
|
}"
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
exports[`t-set t-set, t-if, and mix of expression/body lookup, 1 1`] = `
|
2022-05-26 15:09:09 +02:00
|
|
|
"function anonymous(app, bdom, helpers
|
2020-11-26 16:45:25 +01:00
|
|
|
) {
|
2022-06-08 11:09:39 +02:00
|
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
2021-12-01 17:03:53 +01:00
|
|
|
let { isBoundary, withDefault, setContextValue } = helpers;
|
2020-11-26 16:45:25 +01:00
|
|
|
|
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/><block-child-0/><block-text-0/></div>\`);
|
|
|
|
|
|
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
|
|
|
ctx = Object.create(ctx);
|
2021-10-19 11:00:26 +02:00
|
|
|
ctx[isBoundary] = 1
|
2020-11-26 16:45:25 +01:00
|
|
|
if (ctx['flag']) {
|
2021-10-19 11:00:26 +02:00
|
|
|
setContextValue(ctx, \\"ourvar\\", \`1\`);
|
2020-11-26 16:45:25 +01:00
|
|
|
} else {
|
2021-10-19 11:00:26 +02:00
|
|
|
setContextValue(ctx, \\"ourvar\\", 0);
|
2020-11-26 16:45:25 +01:00
|
|
|
}
|
2021-12-22 11:33:12 +01:00
|
|
|
let txt1 = ctx['ourvar'];
|
|
|
|
|
return block1([txt1]);
|
2020-11-26 16:45:25 +01:00
|
|
|
}
|
|
|
|
|
}"
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
exports[`t-set t-set, t-if, and mix of expression/body lookup, 2 1`] = `
|
2022-05-26 15:09:09 +02:00
|
|
|
"function anonymous(app, bdom, helpers
|
2020-11-26 16:45:25 +01:00
|
|
|
) {
|
2022-06-08 11:09:39 +02:00
|
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
2021-12-01 17:03:53 +01:00
|
|
|
let { isBoundary, withDefault, setContextValue } = helpers;
|
2020-11-26 16:45:25 +01:00
|
|
|
|
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/><block-child-0/><block-text-0/></div>\`);
|
|
|
|
|
|
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
|
|
|
ctx = Object.create(ctx);
|
2021-10-19 11:00:26 +02:00
|
|
|
ctx[isBoundary] = 1
|
2020-11-26 16:45:25 +01:00
|
|
|
if (ctx['flag']) {
|
2021-10-19 11:00:26 +02:00
|
|
|
setContextValue(ctx, \\"ourvar\\", 1);
|
2020-11-26 16:45:25 +01:00
|
|
|
} else {
|
2021-10-19 11:00:26 +02:00
|
|
|
setContextValue(ctx, \\"ourvar\\", \`0\`);
|
2020-11-26 16:45:25 +01:00
|
|
|
}
|
2021-12-22 11:33:12 +01:00
|
|
|
let txt1 = ctx['ourvar'];
|
|
|
|
|
return block1([txt1]);
|
2020-11-26 16:45:25 +01:00
|
|
|
}
|
|
|
|
|
}"
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
exports[`t-set t-set, t-if, and mix of expression/body lookup, 3 1`] = `
|
2022-05-26 15:09:09 +02:00
|
|
|
"function anonymous(app, bdom, helpers
|
2020-11-26 16:45:25 +01:00
|
|
|
) {
|
2022-06-08 11:09:39 +02:00
|
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
2021-12-01 17:03:53 +01:00
|
|
|
let { isBoundary, withDefault, setContextValue } = helpers;
|
2020-11-26 16:45:25 +01:00
|
|
|
|
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
|
|
|
ctx = Object.create(ctx);
|
2021-10-19 11:00:26 +02:00
|
|
|
ctx[isBoundary] = 1
|
2020-11-26 16:45:25 +01:00
|
|
|
let b2;
|
|
|
|
|
if (ctx['flag']) {
|
2021-10-19 11:00:26 +02:00
|
|
|
setContextValue(ctx, \\"ourvar\\", 1);
|
2020-11-26 16:45:25 +01:00
|
|
|
} else {
|
2021-10-19 11:00:26 +02:00
|
|
|
setContextValue(ctx, \\"ourvar\\", \`0\`);
|
2020-11-26 16:45:25 +01:00
|
|
|
}
|
|
|
|
|
b2 = text(ctx['ourvar']);
|
|
|
|
|
return multi([b2]);
|
|
|
|
|
}
|
|
|
|
|
}"
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
exports[`t-set value priority (with non text body 1`] = `
|
2022-05-26 15:09:09 +02:00
|
|
|
"function anonymous(app, bdom, helpers
|
2020-11-26 16:45:25 +01:00
|
|
|
) {
|
2022-06-08 11:09:39 +02:00
|
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
2021-12-22 15:06:28 +01:00
|
|
|
let { isBoundary, withDefault, LazyValue } = helpers;
|
2020-11-26 16:45:25 +01:00
|
|
|
|
|
|
|
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
|
|
|
|
let block2 = createBlock(\`<span>2</span>\`);
|
|
|
|
|
|
2021-12-22 15:06:28 +01:00
|
|
|
function value1(ctx, node, key = \\"\\") {
|
|
|
|
|
return block2();
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-26 16:45:25 +01:00
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
|
|
|
ctx = Object.create(ctx);
|
2021-10-19 11:00:26 +02:00
|
|
|
ctx[isBoundary] = 1
|
2022-06-22 15:39:31 +02:00
|
|
|
ctx[\`value\`] = withDefault(1, new LazyValue(value1, ctx, this, node));
|
2021-12-22 11:33:12 +01:00
|
|
|
let txt1 = ctx['value'];
|
|
|
|
|
return block1([txt1]);
|
2020-11-26 16:45:25 +01:00
|
|
|
}
|
|
|
|
|
}"
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
exports[`t-set value priority 1`] = `
|
2022-05-26 15:09:09 +02:00
|
|
|
"function anonymous(app, bdom, helpers
|
2020-11-26 16:45:25 +01:00
|
|
|
) {
|
2022-06-08 11:09:39 +02:00
|
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
2021-12-01 17:03:53 +01:00
|
|
|
let { isBoundary, withDefault, setContextValue } = helpers;
|
2020-11-26 16:45:25 +01:00
|
|
|
|
|
|
|
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
|
|
|
|
|
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
|
|
|
ctx = Object.create(ctx);
|
2021-10-19 11:00:26 +02:00
|
|
|
ctx[isBoundary] = 1
|
|
|
|
|
setContextValue(ctx, \\"value\\", withDefault(1, \`2\`));
|
2021-12-22 11:33:12 +01:00
|
|
|
let txt1 = ctx['value'];
|
|
|
|
|
return block1([txt1]);
|
2020-11-26 16:45:25 +01:00
|
|
|
}
|
|
|
|
|
}"
|
|
|
|
|
`;
|