t-debug now add a debugger in top of the compiled function

This commit is contained in:
Géry Debongnie
2019-02-06 11:20:45 +01:00
parent 9299cb5df3
commit 7b5610802a
+5 -1
View File
@@ -233,6 +233,7 @@ export class QWeb {
}
const mainNode = this.processedTemplates[name];
const isDebug = (<Element>mainNode).attributes.hasOwnProperty("t-debug");
const ctx = new Context();
this._compileNode(mainNode, ctx);
@@ -249,12 +250,15 @@ export class QWeb {
throw new Error("A template should have one root node");
}
ctx.addLine(`return vn${ctx.rootNode};`);
if (isDebug) {
ctx.code.unshift(" debugger");
}
let template = new Function(
"context",
"extra",
ctx.code.join("\n")
) as CompiledTemplate<VNode>;
if ((<Element>mainNode).attributes.hasOwnProperty("t-debug")) {
if (isDebug) {
console.log(
`Template: ${
this.processedTemplates[name].outerHTML