I think that the use of template engines depends solely on the development team. Not everyone can work with template engines, which causes development difficulties. And so itβs your business. There is no strong difference. In the case of Twig, there is no waste of resources - the template is translated into the same PHP code. Templates are needed to separate business logic and display logic.
Example number 1: the same core is installed on different sites. If standardization is used, updating the engine is reduced to a simple code fill. If standardization is not used, then for each site core must be edited separately.
Example # 2: the same application can return both HTML and JSON. If a template was used for the first, then you can add the second without touching the code. Otherwise, the code will have to be rewritten (and duplicated).
Also dug up an example of Native vs Twig (Yii2):
Native yii2
<? echo $user->percent?$user->percent:0; ?> <? echo $user->getTotalLikes(); ?> <? if ($user->countComments > 0): ?> <? $this->renderPartial('//user/_comments', array('comments'=>$user->comments)); ?> <? else: ?> <div style="padding-left: 35px;"><? echo Yii::t('user', 'ΠΡ Π½Π΅ Π΄ΠΎΠ±Π°Π²Π»ΡΠ»ΠΈ ΠΊΠΎΠΌΠΌΠ΅Π½ΡΠ°ΡΠΈΠ΅Π² ΠΊ ΠΏΠΎΡΡΠ°ΠΌ'); ?>.</div> <? endif; ?> <p><? if (!empty($ct['parent']->image)): ?><img src="<?php echo $ct['parent']->getImageUrl('small'); ?>"><? endif; ?> <? echo Yii::app()->createUrl('user/register', array('ref'=>$user->id)); ?>
Twig yii2
{{ user.percent|default(0) }} {{ user.getTotalLikes() }} {% if user.countComments %} {% include "views/user/_comments.twig" %} {% else %} <div style="padding-left: 35px;">{{ Yii.t('user', 'ΠΡ Π½Π΅ Π΄ΠΎΠ±Π°Π²Π»ΡΠ»ΠΈ ΠΊΠΎΠΌΠΌΠ΅Π½ΡΠ°ΡΠΈΠ΅Π² ΠΊ ΠΏΠΎΡΡΠ°ΠΌ') }}.</div> {% endif %} <p>{% if comment.getImageUrl %}<img src="{{ comment.getImageUrl('small') }}">{% endif %} /user/register?ref={{ user.id }}
PS You might also like Smarty. The choice is individual for everyone. Successful coding ...