S
S
Stepan2015-09-02 00:33:52
Yii
Stepan, 2015-09-02 00:33:52

Why is twig needed if even a widget cannot be inserted into it?

Why is twig needed if even a widget cannot be inserted into it?
Having to mix .php and twig
Which is not what I need at all. Taking into account the fact that I also have JS template engines, it turns out to be a complete mess
. You can call a function for each fart, but this is a hassle for a large application.
Or am I misunderstanding something?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vitaly Khomenko, 2015-09-02
@xoma2

Twig is a great tool. But in Yii2, it is generally not needed. He'll get in the way there. The bottom line is that in Yii2, templates are highly integrated into the framework: layouts, widgets, meta tag registration, assets, caching, and more. Everything you need when working with templates is already there.
At one time, before starting work on a large project, we also had the question of a template engine. Also considered Twig. But after a thorough study of the framework, the connection of an external template engine was immediately discarded. And over the past year, they have never regretted such a decision.
There is really one place where you can't do without an external template engine. But that is another story :)

A
Andrey Pavlenko, 2015-09-02
@Akdmeh

Twig may be needed in Yii if there is a need to be able to edit templates by the end user thanks to the sandboxing feature.
In all other cases, it's just a matter of convenience - built-in Yii widgets have a huge advantage in the speed of developing typical sections of code (outputting page entries, standard jQuery UI plugins, etc.), and therefore if you switch to Twig - this should be justified by some then the goal, not "I'll do it just for fun".

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question