I am using express-hbs nodejs module and I have a problem using registerAsyncHelper. I need to compile the layout in the scope of the constraint, because of this I created a new instance of Handlebars, and I created a helper in this instance. But when I compile the layout, it returns a weird hash. My code looks something like this:
var hbs = require('express-hbs');
var hbs_temp = hbs.create();
hbs_temp.registerAsyncHelper( 'content', function( text, cb ) {
fs.readFile( 'some-file', { encoding: 'utf8' }, function( err, data ) {
cb( new hbs_temp.SafeString( data ) );
});
});
hbs_temp.compile( '<div> {{content}} </div>' )( );`
Result:
<div> __WEIRD HASH__ </div>
My question is. Is there something wrong with my code, or is it an "express-hbs" error? Thank!
source
share