Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ember 2.10.0+ migration to glimmer / removal of ember-handlebars breaks outlet keyword. #2

Open
microfauna opened this issue Dec 13, 2016 · 1 comment

Comments

@microfauna
Copy link

I started looking into replacing it but it seems quite involved.

@microfauna microfauna changed the title Ember 2.10.0+ migration to glimmer / removal of ember-handlebars breaks outlet keyword. Ember 2.10.0+ migration to glimmer / removal of ember-handlebars breaks outlet keyword. Dec 13, 2016
@microfauna
Copy link
Author

I got started on a basic hack to get this working - it's surely not the best way to go about it and still needs to load parent model, target and have an "into" specified - but it's a start, no?

  Ember.Route.reopen({
    controllerFor(name, _skipAssert) {
      let owner = Ember.getOwner(this);
      let route = owner.lookup(`route:${name}`);
      let controller;

      if (route && route.controllerName) {
        name = route.controllerName;
      }

      controller = owner.lookup(`component:${name}`);

      if (!controller) {
        return this._super.apply(this, arguments);
      }

      return controller;
    },

    render(_name, options) {
      let name;

      console.log(this.templateName, this.routeName, options);
      if (typeof _name === 'object' && !options) {
        name = this.templateName || this.routeName;
        options = _name;
      } else {
        name = (_name && _name.replace(/\//g, '.')) || this.routeName;
      }

      let templateName = "components/" + (this.templateName || name);

      let owner = Ember.getOwner(this);
      let into = options && options.into && options.into.replace(/\//g, '.');
      let outlet = (options && options.outlet) || 'main';
      
      let controller = owner.lookup(`component:${name}`);

      if (!controller) {
        this._super.apply(this, arguments);
      } else {
        let template = owner.lookup(`template:${templateName}`);
        console.log(Ember.Route.parentRoute(this));

        let renderOptions = {
          owner,
          into,
          outlet,
          name,
          controller,
          template,
          ViewClass: undefined
        };

        this.connections.push(renderOptions);
        Ember.run.once(this.router, '_setOutlets');
      }
    }
  });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant