Just place the new template in the templates
folder of your theme/theme-component.
Use the resolver to find the template. Something like below in init
or didReceiveAttrs
callback(doesn’t work on callbacks after these two). Set the component’s layout property as the custom template.
@on('init')
overrideTemplate(){
const template = getOwner(this).lookup(`template:your-template-filename`);
this.set('layout', template);
}
Notes:
- The filename passed in the resolver should be without
.hbs
. - This method works for components using regular templates. For overriding raw templates programatically, have a look at https://thepavilion.io/t/how-to-override-raw-templates-programatically-via-plugins-theme-components/2440