|
|
|
|
|
by mamadrood
3462 days ago
|
|
I've been using PHP for most of my life, and used various template engine and it always end up with one question : what is the real purpose of a template engine in PHP instead of just using PHP ? When I see the examples in twig homepage it just looks like they tried to make PHP examples verbose for the sake of it. I don't really mind them, but I find it extremely boring to have to register in the template engine every function that you will end up using somewhere else in your code and eventually have a language with less feature than plain old PHP and an other layer of cache. So which use cases make you need Twig, for instance ? |
|
It also makes it easier to separate your presentation logic from your business logic.
For example: https://github.com/paragonie/airship/blob/master/src/Cabin/B...
This uses macros and other fun things. Doing that in PHP would get messy.
https://github.com/paragonie/airship/blob/master/src/Cabin/B...