I am deciding if to use some template engine in php code or no.
Now I take close look to Smarty.
To be honest, it is not clear for me its benefits.
My impressions are not very good from the very beginning.
I tried to go through the demo application: http://www.smarty.net/sampleapp1. And from the very beginning I obtained notices . I fixed this by passing values to forms.
I changes the code from
// adding a guestbook entry
$guestbook->displayForm();
to
// adding a guestbook entry
$guestbook->displayForm(array('Name' => '', 'Comment' => ''));
While guessing this I understand that it complicates debugging the code.
And this also makes me to learn one more language – it is easy, but most easy is not to learn something new at all if there is no needed.
Alternative is to use PHP itself.
Syntax comparison http://www.smarty.net/syntax_comparison is most funny for me: calculate number of symbols…. But I am familiar with PHP and this is easy for me to write on it, and Smarty is new for me. And I don’t think that for Web Designers are so difficult to learn some simple php constructs, and Smarty is so simpler in this respect. If I am wrong it would be good to hear web designer here.
Smarty parses the code and this is in fact time overhead.
But at the same time many people use it. And that is why I would like to understand the reasons for this?
Where are the benefits? Am I missing something?
If you know good alternative to Smarty, it would be good to know about.
Thanks!
UPDATE:
I have found also the question on subject: How to use Smarty better with PHP?. In general it is also about not to use Smarty. But this is 1.5 years old. Possibly something changed?
I agree that it causes overhead, I worked in a project that used Smarty and it was a nightmare. The two benefits you can get are
1: designers that are not familiar with PHP can work out with your HTML without coding skills required. But doesn’t that mean they will eventually need to study Smarty first? I really don’t see any point.
2: For template separation: you can use PHP alternative syntax the same way you would use Smarty, without losing the power of that giant programming language. Example of alternative syntax: