There is about such a pattern
{% include 'template/header.html' %} <div class="content"> ... </div> {% include 'template/footer.html' %} I need to render it to a file.
var Twig=require('twig'); var file='путь к файлу'; var html = fs.readFileSync(file, 'utf8'); html=Twig.twig( //Вариант 1 {href:file} /* TwigException: Unsupported platform: Unable to do remote requests because there is no XMLHTTPRequest implementation */ //Вариант 2 {data:html} /* TwigException: Cannot extend an inline template. */ ).render({ ... }); console.log(html); fs.writeFile(dest, html, ... дальше все ок How to do it?