bguiz
bguiz

Reputation: 28587

Where to place templates for nested routes in Ember.js apps using pods?

Where should the template files be placed for nested routes when using the pod structure in ember-cli?

Here is what I have at the moment.

Router:

Router.map(function() {
    this.resource('foo', function() {
        this.resource('foo.bar', function() {
        });
    ));
    /* ... */
});

Folder Structure:

/app/pods
    /foo
        controller.js
        route.js
        template.hbs
        /bar
            controller.js
            route.js
            template.hbs

Should I be defining my routes differently or naming my files differently?

Upvotes: 2

Views: 843

Answers (1)

agriboz
agriboz

Reputation: 4854

In the documentation page, it says "app/templates/ Your Handlebars templates. These are compiled to templates.js. The templates are named the same as their filename, minus the extension (i.e. templates/foo/bar.hbs -> foo/bar)."

Actual result: "Error: Assertion Failed: The URL '/foo/aa' did not match any routes in your application"

It is searching for /foo/bar/bar.hbs , however your case is /foo/bar/template.hbs

Naming convention is the key role of ember.js.

Route

Router.map(function() {
    this.resource('foo', function() {
        this.resource('bar', function() { // 'bar' route nested in 'foo' route

        });  
    });
});

Getting Started

Upvotes: 1

Related Questions