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 http://twig.sensiolabs.org/

Pages, what if found most usable are these:
http://twig.sensiolabs.org/doc/templates.html
http://twig.sensiolabs.org/doc/api.html

You can find introduction to Twig on Symofny's page too
here: http://symfony.com/doc/2.0/book/templating.html
and here: http://symfony.com/doc/2.0/cookbook/templating/index.html
and here: http://symfony.com/doc/2.0/components/templating.html

You can see default Twig's configuration in Symofny 2 here:
http://symfony.com/doc/2.0/reference/configuration/twig.html

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!