AMI-TWIG.js is a JavaScript implementation for both NodeJS and browsers of the SensioLabs's TWIG template engine.
let amiTwig = require('ami-twig.min.js').amiTwig;
<script type="text/javascript" src="ami-twig.min.js"></script>
let textResult = amiTwig.engine.render(twigTemplate, optionalDict, optionalTwigTemplates);
where optionalDict contains all the global variables for the template.
For optimization perposes, templates can be compiled before rendering:
let compiledTemplate = amiTwig.engine.compile(twigTemplate);
let textResult = amiTwig.engine.render(compiledTemplate, optionalDict, optionalTwigTemplates);