mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[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:
@@ -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;
|
||||
|
||||
@@ -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}}__`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user