Here is a brief overview of using Twig inside OpenEMR.
https://www.open-emr.org/wiki/index.php/Twig_Development