I am trying to achieve a similar functionality as demonstrated in this Stack Overflow answer using this library.
Below is the code snippet I have written:
var expressHandlebars = require('express-handlebars');
var Handlebars = expressHandlebars.create({
....
helpers: {
partial: function(partialName, context, hash) {
return Handlebars.getPartials()
.then(function(partials){
return partials[partialName](context, hash);
});
}
}
})
I am trying to use it like this:
{{{partial partialName this}}} <!-- partialName is a variable -->
However, the output I get is
[object Object]
,
which represents a Promise instance.
How can I access the template content successfully?