Answer the question
In order to leave comments, you need to log in
Handlebars: how to connect one template inside another and write a helper to it?
Hello.
There is a .hbs template that includes the page header
{{partial "header"}}
<div>...</div>
let template = Handlebars.registerHelper('partial', function (html, context) {
// здесь нужно обрабатывать паршлс?
});
Answer the question
In order to leave comments, you need to log in
More or less like this:
Handlebars.registerHelper('partial', function(template, context) {
if(!Handlebars.templates[template]) return '';
return new Handlebars.SafeString(Handlebars.templates[template](context));
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question