Domovoy wrote:
As you see, the second example (a template engine I'm looking for) is easier for understanding and modifying. Moreover, you can open the second code in a browser.
Ah. Well, thats quite a bit different then most template systems I've seen. Now I understand better what you were looking for - good luck in finding it.
Domovoy wrote:
Just enable "E_STRICT" option in php.ini. Smarty isn't designed for PHP5 for now.
E_STRICT doesnt determine whether something will *run* in PHP5 - it helps clean up issues that could be *improved* for PHP5:
"A new error level, E_STRICT has been introduced to PHP 5 by Andi Gutmans. It will be switched off by default, and is for
"purists can use to make sure that there scripts are using the latest and greatest suggested method of coding (according to what we decide)." " -
http://www.zend.com/zend/week/week162.php
I'll say it again - Smarty runs perfectly well under PHP5, and with E_ALL (not purist-mode), it shows no warnings. You'll find that the vast majority of large php apps and libraries all fit in this category at this point (Serendipity, Adodb, phpmailer, phpbb...).
Methinks you have an unreasonable expectation for existing codebases - PHP5 has only been out for four months, and Smarty has almost 10,000 lines of code. The fact that it works - flawlessly - in PHP5 is impressive enough.
Domovoy wrote:
And what is the difference in the example above? Why I should use Smarty?
Multiple reasons:
- The files arent seperate. (Arguably, you could easily make them so)
- The template you used cant be opened by an editor without errors - with Smarty's templates, dreamweaver does just fine.
- You dont get caching for free
Like with any discussion about template engines - there is a fine line between using it and using PHP, which I already said. You clearly want a template engine already, so I dont see much need to defend the choice of using a template engine in general.
Domovoy wrote:
No, I meant the "behind the scenes" compilation (i.e. template to PHP). Even if a template was compiled, Smarty will check this every time a customer opens your site. And if there are "many" templates it will slow down your site.
If you seperate output from processing, there will always be an overhead, period. To include the file, to check it, what have you. In my testing, I show the overall overhead of having smarty doing templates as low as 0.02% and at its highest at roughly 0.64%. When I compare it against doing simple file inclusion, the numbers are even lower.
Arguably, thats different from "No overhead", but its trivial. Yahoo uses it and they scale just fine.. My experiences are no different.
Domovoy wrote:
Actually, I have 2-years experience with Smarty. And now I see that there is no real difference between Smarty and PHP itself. Therefore I'm trying to find a better solution (template engine).
Ah. Well, we'll have to agree to disagree on that point. There are huge differences in my opinion.