mardi 11 septembre 2018

Ember can't find my template when using the renderTemplate hook

I can’t figure out why Ember can’t find and render the template specified in my renderTemplate hook override. I have the following route configuration as per router.js:

  this.route('posts', function() {
   this.route('history', function() {
    this.route('new', { path: '/new/:id'});
   });
  });

I’m also making use of my history index route. Therefore, my history.hbs is just an outlet, and all my templating for this route is actually housed in index.hbs. This way, I can render my new.hbs template on its own page.

In new.hbs, I’d like to render an outlet, in addition to some other content. To handle this, I attempted to override the renderTemplate hook in routes/new.js, like this:

  renderTemplate() {
   this.render('posts/history/test', {
    into: 'new',
    outlet: 'test',
   });
  }

I created the new template under templates/posts/history:test.hbs`. File structure for my templates folder looks like this:

templates > posts > history > new.hbs, test.hbs

Finally, in new.hbs, I added my outlet for this new template:

When I navigate to my new route, I get the following error: Assertion Failed: You attempted to render into ’new' but it was not found. Anyone know how I can get past this?




Aucun commentaire:

Enregistrer un commentaire