[FIX] qweb: support #{} syntax in attribute string interpolation

closes #113
This commit is contained in:
Géry Debongnie
2019-05-17 16:14:54 +02:00
parent a1e982aba5
commit a1d7e6c987
4 changed files with 42 additions and 7 deletions
+6 -4
View File
@@ -457,6 +457,9 @@ export class QWeb {
props.push(`${key}: _${val}`);
}
}
function formatter(expr) {
return "${" + ctx.formatExpression(expr) + "}";
}
for (let i = 0; i < attributes.length; i++) {
let name = attributes[i].name;
@@ -515,10 +518,9 @@ export class QWeb {
// attribute contains 'non letters' => we want to quote it
attName = '"' + attName + '"';
}
const formattedExpr = value!.replace(
/\{\{.*?\}\}/g,
s => "${" + ctx.formatExpression(s.slice(2, -2)) + "}"
);
const formattedExpr = value!
.replace(/\{\{.*?\}\}/g, s => formatter(s.slice(2, -2)))
.replace(/\#\{.*?\}/g, s => formatter(s.slice(2, -1)));
const attID = ctx.generateID();
let staticVal = (<Element>node).getAttribute(attName);
if (staticVal) {