ember-rails
ember-rails copied to clipboard
Better documentation of the folder conventions and nested template structure
This may just be me not understanding the conventions of ember-rails. But can someone explain the idiomatic way to nest handlebars templates in an ember-rails based project?
For example assuming the following route structure:
App.Router.map(function() {
this.resource('solutions', function() {
this.route('new');
this.resource('solution', { path: ':solution_id' }, function() {
this.route('overview', { path: 'overview' });
this.route('edit', { path: 'edit' });
});
});
}); // map
It would seem idiomatic to recursively nest folders to match the router nesting
/app
|-assets/
|---javascripts/
|-----myapp/
|-------templates/
|---------solutions.handlebars
|---------solutions/
|-----------index.handlebars
|-----------new.handlebars
|-----------solution/
|-------------index.handlebars
|-------------overview.handlebars
|-------------edit.handlebars
But ember rails seems to require the following directory structure. e.g the "solution" directory is outside the "solutions" directory:
/app
|-assets/
|---javascripts/
|-----myapp/
|-------templates/
|---------solutions.handlebars
|---------solutions/
|-----------index.handlebars
|-----------new.handlebars
|---------solution/
|-----------index.handlebars
|-----------overview.handlebars
|-----------edit.handlebars
Is this a bug? Perhaps some more documentation of implied folder conventions would be helpful. Especially around deeply nested application structures (i.e. more than two levels deep).
I prefer your first example. And yes as apps grow more deeply nested app structure is needed.
Someone should take a shot at addressing this.
@eccegordo - If you could create a sample repo that I could use to test, I'd like to look into addressing this...
@rjackson thanks, good timing, I was just struggling with this yesterday. I think I keep expecting certain nested folders to behave in a specific way and they don't. I started to look at the ember rails source to figure out what was going on. I think there are at least three folder layout variants I can think of. One is more edge case than the others
I will put together a repo to display the expectations.
This is ultimately about compilation of source folders and how they map to conventions and expectations. A learning exercise for me but would love to be able to document and show what happens in the explicit and implicit case (e.g. generated controllers, etc)
I started to look at the dummy app to understand how your tests work.
https://github.com/emberjs/ember-rails/tree/master/test/dummy
Hopefully we can get a few varied test cases together. And from that some explicit documentation.
Will get something shortly.
Really excited about this - happy to help test against our project, which would greatly benefit from folder nesting.