[IMP] qweb: re-add support of t-on directive

We add some test for the t-on directive.

For making them pass, it was necessary to change the code produced by
compileTForeach: the const declaration is not done by using generateId
and there was some conflict with the variable names produced in
captureExpression. Consequently, many snapshots had to be changed.

Code prettification has been done too.
This commit is contained in:
Mathieu Duckerts-Antoine
2021-10-15 13:08:07 +02:00
committed by Aaron Bohy
parent ee1ef20ce1
commit d6668e3439
16 changed files with 628 additions and 326 deletions
+35 -35
View File
@@ -384,20 +384,20 @@ exports[`t-call (template calling) recursive template, part 2 2`] = `
ctx = Object.create(ctx);
let d1 = ctx['node'].val;
ctx = Object.create(ctx);
const [k2, v2, l2, c2] = prepareList(ctx['node'].children||[]);
for (let i1 = 0; i1 < l2; i1++) {
ctx[\`subtree\`] = v2[i1];
const [k_block2, v_block2, l_block2, c_block2] = prepareList(ctx['node'].children||[]);
for (let i1 = 0; i1 < l_block2; i1++) {
ctx[\`subtree\`] = v_block2[i1];
ctx[\`subtree_first\`] = i1 === 0;
ctx[\`subtree_last\`] = i1 === v2.length - 1;
ctx[\`subtree_last\`] = i1 === v_block2.length - 1;
ctx[\`subtree_index\`] = i1;
ctx[\`subtree_value\`] = k2[i1];
ctx[\`subtree_value\`] = k_block2[i1];
let key1 = ctx['subtree_index'];
ctx = Object.create(ctx);
ctx[\`node\`] = ctx['subtree'];
c2[i1] = withKey(callTemplate_2(ctx, node, key + \`__1__\${key1}\`), key1);
c_block2[i1] = withKey(callTemplate_2(ctx, node, key + \`__1__\${key1}\`), key1);
ctx = ctx.__proto__;
}
let b2 = list(c2);
let b2 = list(c_block2);
return block1([d1], [b2]);
}
}"
@@ -435,20 +435,20 @@ exports[`t-call (template calling) recursive template, part 3 2`] = `
ctx = Object.create(ctx);
let d1 = ctx['node'].val;
ctx = Object.create(ctx);
const [k2, v2, l2, c2] = prepareList(ctx['node'].children||[]);
for (let i1 = 0; i1 < l2; i1++) {
ctx[\`subtree\`] = v2[i1];
const [k_block2, v_block2, l_block2, c_block2] = prepareList(ctx['node'].children||[]);
for (let i1 = 0; i1 < l_block2; i1++) {
ctx[\`subtree\`] = v_block2[i1];
ctx[\`subtree_first\`] = i1 === 0;
ctx[\`subtree_last\`] = i1 === v2.length - 1;
ctx[\`subtree_last\`] = i1 === v_block2.length - 1;
ctx[\`subtree_index\`] = i1;
ctx[\`subtree_value\`] = k2[i1];
ctx[\`subtree_value\`] = k_block2[i1];
let key1 = ctx['subtree_index'];
ctx = Object.create(ctx);
ctx[\`node\`] = ctx['subtree'];
c2[i1] = withKey(callTemplate_2(ctx, node, key + \`__1__\${key1}\`), key1);
c_block2[i1] = withKey(callTemplate_2(ctx, node, key + \`__1__\${key1}\`), key1);
ctx = ctx.__proto__;
}
let b2 = list(c2);
let b2 = list(c_block2);
return block1([d1], [b2]);
}
}"
@@ -489,20 +489,20 @@ exports[`t-call (template calling) recursive template, part 4: with t-set recurs
let d1 = ctx['node'].val;
let d2 = ctx['recursive_idx'];
ctx = Object.create(ctx);
const [k2, v2, l2, c2] = prepareList(ctx['node'].children||[]);
for (let i1 = 0; i1 < l2; i1++) {
ctx[\`subtree\`] = v2[i1];
const [k_block2, v_block2, l_block2, c_block2] = prepareList(ctx['node'].children||[]);
for (let i1 = 0; i1 < l_block2; i1++) {
ctx[\`subtree\`] = v_block2[i1];
ctx[\`subtree_first\`] = i1 === 0;
ctx[\`subtree_last\`] = i1 === v2.length - 1;
ctx[\`subtree_last\`] = i1 === v_block2.length - 1;
ctx[\`subtree_index\`] = i1;
ctx[\`subtree_value\`] = k2[i1];
ctx[\`subtree_value\`] = k_block2[i1];
let key1 = ctx['subtree_index'];
ctx = Object.create(ctx);
ctx[\`node\`] = ctx['subtree'];
c2[i1] = withKey(callTemplate_2(ctx, node, key + \`__1__\${key1}\`), key1);
c_block2[i1] = withKey(callTemplate_2(ctx, node, key + \`__1__\${key1}\`), key1);
ctx = ctx.__proto__;
}
let b2 = list(c2);
let b2 = list(c_block2);
return block1([d1, d2], [b2]);
}
}"
@@ -717,21 +717,21 @@ exports[`t-call (template calling) t-call with t-set inside and outside 1`] = `
return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx);
ctx = Object.create(ctx);
const [k2, v2, l2, c2] = prepareList(ctx['list']);
for (let i1 = 0; i1 < l2; i1++) {
ctx[\`v\`] = v2[i1];
const [k_block2, v_block2, l_block2, c_block2] = prepareList(ctx['list']);
for (let i1 = 0; i1 < l_block2; i1++) {
ctx[\`v\`] = v_block2[i1];
ctx[\`v_first\`] = i1 === 0;
ctx[\`v_last\`] = i1 === v2.length - 1;
ctx[\`v_last\`] = i1 === v_block2.length - 1;
ctx[\`v_index\`] = i1;
ctx[\`v_value\`] = k2[i1];
ctx[\`v_value\`] = k_block2[i1];
let key1 = ctx['v_index'];
ctx[\`val\`] = ctx['v'].val;
ctx = Object.create(ctx);
ctx[\`val3\`] = ctx['val']*3;
c2[i1] = withKey(callTemplate_2(ctx, node, key + \`__1__\${key1}\`), key1);
c_block2[i1] = withKey(callTemplate_2(ctx, node, key + \`__1__\${key1}\`), key1);
ctx = ctx.__proto__;
}
let b2 = list(c2);
let b2 = list(c_block2);
return block1([], [b2]);
}
}"
@@ -764,21 +764,21 @@ exports[`t-call (template calling) t-call with t-set inside and outside. 2 1`] =
return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx);
ctx = Object.create(ctx);
const [k2, v2, l2, c2] = prepareList(ctx['list']);
for (let i1 = 0; i1 < l2; i1++) {
ctx[\`v\`] = v2[i1];
const [k_block2, v_block2, l_block2, c_block2] = prepareList(ctx['list']);
for (let i1 = 0; i1 < l_block2; i1++) {
ctx[\`v\`] = v_block2[i1];
ctx[\`v_first\`] = i1 === 0;
ctx[\`v_last\`] = i1 === v2.length - 1;
ctx[\`v_last\`] = i1 === v_block2.length - 1;
ctx[\`v_index\`] = i1;
ctx[\`v_value\`] = k2[i1];
ctx[\`v_value\`] = k_block2[i1];
let key1 = ctx['v_index'];
ctx[\`val\`] = ctx['v'].val;
ctx = Object.create(ctx);
ctx[\`val3\`] = ctx['val']*3;
c2[i1] = withKey(callTemplate_2(ctx, node, key + \`__1__\${key1}\`), key1);
c_block2[i1] = withKey(callTemplate_2(ctx, node, key + \`__1__\${key1}\`), key1);
ctx = ctx.__proto__;
}
let b2 = list(c2);
let b2 = list(c_block2);
return block1([], [b2]);
}
}"