Twig Template Engine

30 Dec 2010

EDIT: nl2br() with Twig tutorial: twig-nl2br

A while back I started to learn django, and I absolutely loved it. However, I was so used to PHP for my web development, I naturally went back.

Then I found Twig! I’ve started using this in my latest project, and oh my! It’s an amazing little template engine. It’s definitely the best one I’ve ever used for PHP and the best thing is the fact it reminds me so much of how django does their templates. It’s very quick and easy to put in new themes, modify them… it’s a life-saver.

Some of the coolest things with Twig, is the fact you can do the whole nl2br (http://php.net/nl2br) stuff inside the template engine, for example:

{{ show_content|nl2br }}

How cool is that?! Another one, is transforming a raw timestamp to something much more readable. Ah, it’s a lifesaver.

I suggest you go visit the Twig site: http://www.twig-project.org/
And read the docs for template design: http://www.twig-project.org/doc/templates.html

P.S. I forgot to mention, the extensions are so easy to code for, and even easier to add to your project!

Tags: , , , ,

· · · ◊ ◊ ◊ · · ·