2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-07 12:02:53 +08:00

Support for HTML values in widget hbs templates

This commit is contained in:
Robin Ward 2017-09-29 09:55:53 -04:00
parent f6c484881b
commit 0caf6a0f7d
4 changed files with 18 additions and 4 deletions

View file

@ -64,7 +64,12 @@ function mustacheValue(node, state) {
return `__iN("${icon}")`;
break;
default:
return `${resolve(path)}`;
if (node.escaped) {
return `${resolve(path)}`;
} else {
state.helpersUsed.rawHtml = true;
return `new __rH({ html: '<span>' + ${resolve(path)} + '</span>'})`;
}
break;
}
}
@ -180,7 +185,10 @@ function compile(template) {
let imports = '';
if (compiler.state.helpersUsed.iconNode) {
imports = "var __iN = Discourse.__widget_helpers.iconNode; ";
imports += "var __iN = Discourse.__widget_helpers.iconNode; ";
}
if (compiler.state.helpersUsed.rawHtml) {
imports += "var __rH = Discourse.__widget_helpers.rawHtml; ";
}
return `function(attrs, state) { ${imports}var _r = [];\n${code}\nreturn _r; }`;