I have an template in Twig(https://www.npmjs.com/package/twig) and I want to get it render to string. I'm using TS.
function getHtml(title: string, message: string): Promise<string> {
const html = await promisify(renderFile)('./template.twig', {
filename: 'template.twig',
settings: {
title,
message,
},
});
return html;
}
But the promise is always pending, even if I use the callback version I can't have the HTML.
import Twig from 'twig';
Twig.renderFile('./path/to/someFile.twig', {foo:'bar'}, (err, html) => {
html; // compiled string
});
And with this call the TS alert that doesn't exist default export...
Thanks!