handlebars-loader icon indicating copy to clipboard operation
handlebars-loader copied to clipboard

Possible to dynamically import (lazy load) handlebars templates with webpack?

Open tarponjargon opened this issue 7 years ago • 1 comments

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.

tarponjargon avatar Aug 03 '18 23:08 tarponjargon

I think you're missing grabbing the default export. Try

import(/* webpackPrefetch: 0 */ './MyTemplate.hbs').then(template => {
     this.contents.innerHTML = template.default();
});

floatingdino avatar Dec 14 '18 03:12 floatingdino