How to use template engine in Symfony 2?

Symfony 2 comes bundled with Twig template engine, so you definitely want to use it. Twig template engine has everything what you need to keep your business logic out of templates and stay on MVC pattern, which is used in Symfony 2. The best thing about Twig template engine is that in many cases it is even faster than raw PHP, because finally it renders to raw and optimised PHP code.

Twig's official page is

Pages, what if found most usable are these:

You can find introduction to Twig on Symofny's page too
and here:
and here:

You can see default Twig's configuration in Symofny 2 here:

I think all Twig and Symfony has great official documentation and there is no need to rewrite anything about Twig here in this blog, that's why I'm just giving links to great sources. To know where to look is as same as good as to have all documentation here.

Happy coding!

No comments:

Post a Comment

You can ask IT questions in comments!