Reputation: 18619
Is there a way to precompile handlebars partials only? I want to leave the variables in tact, but simply assemble the page beforehand.
Here is should the use-case:
.hbs
template{{foo}}
variables in tact..hbs
template can be compiled.Basically, I want to know if there is a way to combine handlebars partials together as a compile step. In other words, only process {{>header}}
, don’t process {{name}}
Upvotes: 2
Views: 599
Reputation: 18619
Handlebars.registerPartial('header', 'im the header, hi \\{{name}}');
Handlebars.registerPartial('footer', 'im the footer, hi \\{{name}}');
document.write(Handlebars.compile('{{>header}}im the body, hi \\{{name}}{{>footer}}')({}));
<script src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.0.3/handlebars.js"></script>
Upvotes: 2