PHP Include alternative in Ember

Hi I am new to javascript sites, I’ve been using php. I’ve chosen Ember, and would like to know how do I include a template file within another?

For example, within my application.hbs I have <header> <nav></nav> </header>

And within application.hbs there is also <footer> <nav> </nav> </footer>

Both <nav> elements contain exactly the same markup. How can I make this its own file and include it into here?

Use a ‘partial’: ember g template navbar

edit templates/navbar.hbs with your navigation.

Insert into application.hbs the partial: {{partial ‘navbar’}}

Ok the CORRECT way to do this is actually make it a component, then output the component anywhere in other templates:

ember g component nav-bar

put navigation template code in newly generated templates/components/nav-bar.hbs

then include this template in other places simply like so: {{nav-bar}}

1 Like

Ok either way will actually work, there is a difference between the two however…

Using a ‘partial’ will grab its data from the same model the template you put it in does…

Whereas a component will access the data passed to it.

… I think anways, but I’m still new to this.