mirror of
https://github.com/discourse/discourse.git
synced 2024-11-27 03:10:46 -06:00
Allow hbs widgets to access their parent state
This commit is contained in:
parent
01c6224ca5
commit
e980322ed6
@ -1,5 +1,11 @@
|
||||
function resolve(path) {
|
||||
return (path.indexOf('settings') === 0) ? `this.${path}` : path;
|
||||
if (path.indexOf('settings') === 0) {
|
||||
return `this.${path}`;
|
||||
} else if (path.indexOf('parentState') === 0) {
|
||||
return `attrs._${path}`;
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
function mustacheValue(node, state) {
|
||||
@ -8,7 +14,7 @@ function mustacheValue(node, state) {
|
||||
switch(path) {
|
||||
case 'attach':
|
||||
const widgetName = node.hash.pairs.find(p => p.key === "widget").value.value;
|
||||
return `this.attach("${widgetName}", attrs, state)`;
|
||||
return `this.attach("${widgetName}", state ? $.extend({}, attrs, { _parentState: state }) : attrs)`;
|
||||
break;
|
||||
case 'yield':
|
||||
return `this.attrs.contents()`;
|
||||
|
Loading…
Reference in New Issue
Block a user