Hi, i'm __edorian.
I'm a magic method. Apart from that a php/mysql/web guy and a gamer... among other stuff
We, as in the php community, are still talking about frameworks (a lot!) so this horse can’t be that dead either.
If you read some of my previous posts you know me as a “clean code” guy. I like readable, understandable and maintainable code. The same goes for templates. I need to be able to parse very quickly what is happening.. at least i want to.
So let me just show you a picture:

While this is a darn simple template let me just ask you: Which one do you think is more readable?
All technical concerns aside I’ll just have to go for the Twig template here. Even not factoring in things like escaping, including of more complex structures and more complex iterations or function calls i just like it better.
Especially the line:
<?php } ?>
is just so painful to look that i don’t want to do any templateing in pure php.
Maybe some of that can be worked around with old syntax and the short open tag but it’s still no pretty. And since i don’t have projects there using something like Twig is a downside of any kind (or whatever reasons you might bring up) for now it seems to be the nicest thing out there.
Comments 6 Comments
<?php foreach($foo as $bar): ?>
<?php endforeach; ?>
It's a few more characters than the Twig example, but if you're just going for readability, those could help.
"Short open tags" is mentioned, but also not used in the picture.
Also, let's see an example where you have to call methods on the passed objects in the template, for example getters on a model.