icholy / ember-brunch

80 stars 23 forks source link

handlebars template name for templates like "posts/index"? #13

Closed inconduit closed 11 years ago

inconduit commented 11 years ago

i assume that the data-template-name for a handlebars template is inferred from the .hbs template file by brunch?

what about template names in the new ember router? for example, a posts.index Route would have data-template-name="posts/index". obviously a filename can't have a slash in it, so what would you name the .hbs file for that template?

seankeating commented 11 years ago

Brunch builds and defines the template name based on it's file location in the app folder. So, /templates/anotherFolder/yetAnotherFolder/newHandleBarsFile.hbs would be defined as templates/anotherFolder/yetAnotherFolder/newHandleBarsFile

Since this doesn't work with the automatic route/template/etc matching that Ember does we define the 'templateName' in the view for the expected route so it knows where to get the template.

For your example you'd want to have a file/folder structure: templates/posts/index.hbs, but because brunch builds this with 'templates' in the name, and so Ember itself won't find it. So you will want to define it in the view as tempalateName: 'templates/posts/index. The route would just be posts.index.

@icholy if we can make it so that it doesn't define compiled templates with 'templates' in the beginning we could take more advantage of the Ember automatic goodness, and eliminate the current implementation of views from the example.

inconduit commented 11 years ago

that makes sense, thank you kindly. i was unable to find any of that information in the brunch.io docs, and this is the first time i've tried brunch.

On 2013-01-24, at 10:50 AM, Sean Keating wrote:

Brunch builds and defines the template name based on it's file location in the app folder. So, /templates/anotherFolder/yetAnotherFolder/newHandleBarsFile.hbs would be defined as templates/anotherFolder/yetAnotherFolder/newHandleBarsFile

Since this doesn't work with the automatic route/template/etc matching that Ember does we define the 'templateName' in the view for the expected route so it knows where to get the template.

For your example you'd want to have a file/folder structure: templates/posts/index.hbs, but because brunch builds this with 'templates' in the name, and so Ember itself won't find it. So you will want to define it in the view as tempalateName: 'templates/posts/index. The route would just be posts.index.

— Reply to this email directly or view it on GitHub.

icholy commented 11 years ago

@seankeating yeah that's a good idea.

icholy commented 11 years ago

I've update ember-handlebars-brunch to use files.templates.root so this works now. I've went ahead and removed all the explicit controllers & views which get automatically generated.