handlebars-loader
handlebars-loader copied to clipboard
Possible to dynamically import (lazy load) handlebars templates with webpack?
Tried doing stuff like:
import(/* webpackPrefetch: 0 */ './MyTemplate.hbs').then(template => {
this.contents.innerHTML = template();
});
No luck yet. Getting 'template is not a function'. Just wondering if it's possible.
I think you're missing grabbing the default export. Try
import(/* webpackPrefetch: 0 */ './MyTemplate.hbs').then(template => {
this.contents.innerHTML = template.default();
});