[IMP] qweb: slightly simplify generated templates

- In some cases, we can simply inline a template key instead of assigning
  it to a variable and then using that variable
- Add component name in generated code for components
This commit is contained in:
Géry Debongnie
2019-12-12 09:24:07 +01:00
committed by aab-odoo
parent 08022b49df
commit f517d44e32
9 changed files with 400 additions and 432 deletions
+1 -1
View File
@@ -189,7 +189,7 @@ QWeb.addDirective({
extraNames: ["props"],
priority: 100,
atNodeEncounter({ ctx, value, node, qweb }): boolean {
ctx.addLine("//COMPONENT");
ctx.addLine(`// Component '${value}'`);
ctx.rootContext.shouldDefineQWeb = true;
ctx.rootContext.shouldDefineParent = true;
ctx.rootContext.shouldDefineUtils = true;
+4 -1
View File
@@ -48,7 +48,10 @@ export class CompilationContext {
*/
generateTemplateKey(): string {
const id = this.generateID();
let locationExpr = `\`__${this.generateID()}__`;
if (this.loopNumber === 0 && !this.currentKey) {
return `'__${id}__'`;
}
let locationExpr = `\`__${id}__`;
for (let i = 0; i < this.loopNumber - 1; i++) {
locationExpr += `\${i${i + 1}}__`;
}