HTMLBars support for `plugin-outlet`

This commit is contained in:
Robin Ward 2015-05-04 14:36:17 -04:00
parent df3c19705f
commit 82a4066993
1 changed files with 9 additions and 10 deletions

View File

@ -99,11 +99,10 @@ function buildConnectorCache() {
}); });
} }
export default function(connectionName, options) { Ember.HTMLBars._registerHelper('plugin-outlet', function(params, hash, options, env) {
if (!_connectorCache) { buildConnectorCache(); } const connectionName = params[0];
console.warn('plugin outlets are disabled'); if (!_connectorCache) { buildConnectorCache(); }
return;
if (_connectorCache[connectionName]) { if (_connectorCache[connectionName]) {
const childViews = _connectorCache[connectionName]; const childViews = _connectorCache[connectionName];
@ -113,9 +112,9 @@ export default function(connectionName, options) {
const viewClass = (childViews.length > 1) ? Ember.ContainerView : childViews[0]; const viewClass = (childViews.length > 1) ? Ember.ContainerView : childViews[0];
delete options.fn; // we don't need the default template since we have a connector delete options.fn; // we don't need the default template since we have a connector
Ember.Handlebars.helpers.view.call(this, viewClass, options); env.helpers.view.helperFunction.call(this, [viewClass], hash, options, env);
const cvs = options.data.view._childViews; const cvs = env.data.view._childViews;
if (childViews.length > 1 && cvs && cvs.length) { if (childViews.length > 1 && cvs && cvs.length) {
const inserted = cvs[cvs.length-1]; const inserted = cvs[cvs.length-1];
if (inserted) { if (inserted) {
@ -127,13 +126,13 @@ export default function(connectionName, options) {
} else if (options.fn) { } else if (options.fn) {
// If a block is passed, render its content. // If a block is passed, render its content.
return Ember.Handlebars.helpers.view.call(this, return Ember.Handlebars.helpers.view.call(this,
Ember.View.extend({ [Ember.View.extend({
isVirtual: true, isVirtual: true,
tagName: '', tagName: '',
template: function() { template: function() {
return options.hash.template; return options.hash.template;
}.property() }.property()
}), })],
options); hash, options, env);
} }
} });