mistahenry
mistahenry

Reputation: 8724

Ember CLI pod structure - place extra templates in each pod

I've just migrated an Ember app to use the pod structure by adding the podModulePrefix property to my application. All route templates, the controller backing the route template, and the route itself exist under:

app/
  modules/
    route_name/
         template.hbs
         controller.js
         route.js

Now I do a lot of manually switching out of templates with named outlets. So the route template may contain two named outlets, and there's 4 or 5 templates that can be rendered into these outlets at any one time. As of now, these extra templates are sitting in the Ember-CLI created templates directory:

app/
  templates/
     route_name/
        temp1
        temp2

One action that might exist on a route of mine could contain this call:

this.render('route_name/temp1', {outlet: 'named', into: 'route_name'});

What are the steps necessary to make it so templates placed in a templates folder on a pod are resolvable:

app/
  modules/
    route_name/
       template.hbs
       controller.js
       route.js
       templates/
         temp1

And how would I then reference temp1 in this.render()?

Upvotes: 3

Views: 874

Answers (1)

geoffreyd
geoffreyd

Reputation: 1099

This is done by creating a folder with the name you want and putting template.hbs inside.

app/
  modules/
    route_name/
       template.hbs
       controller.js
       route.js
       temp1/
         template.hbs

Pods are not all or nothing, so you can also create a template in:

app/
  modules/
    ...
  templates/
    route_name/
      temp1.hbs

The resolver will first look in pod path, then fall back to 'traditional' locations. To see this happening, you can enable ENV.APP.LOG_RESOLVER = true; in your environment.js

Upvotes: 6

Related Questions