The template engine is a library or framework that separates logic from template files. These libraries provide their own syntaxes for passing the necessary values to the template from the controllers or models. Once successfully implemented, we shouldn't have complex code inside template files other than simple if-else statements and loops.
There are plenty of open source template engines available for PHP. Smarty, Mustache, and Twig are some of the popular ones among them. However, integrating this type of template engine in WordPress is a complex task, compared to using it in other PHP frameworks. The architecture of WordPress is different from any other PHP framework, as it drives on action hooks and filters. Therefore, the integration needs to be capable of handling WordPress-specific things such as actions, filters, widgets, template tags, and so on.