@denis
To add templates to sub-directories in Ember.js, you can follow these steps:
- Create a new directory inside the templates directory of your Ember app. For example, you can create a directory named sub-templates.
- Inside the newly created directory, add the template file that you want to use. For example, you can create a file named my-template.hbs.
- To reference the template in your route or component, you can use dot notation to specify the path to the template file. For example, if you want to use the my-template.hbs file in a route named example, you can define the template like this:
1
2
3
4
5
|
import Route from '@ember/routing/route';
export default class ExampleRoute extends Route {
templateName = 'sub-templates.my-template';
}
|
- Make sure to include the appropriate import statement if you are using typescript in your Ember app.
By following these steps, you can add templates to sub-directories in Ember.js and organize your templates in a more structured way.