Heya,

I would like to start a discussion on whether we should adopt Twig as
the *default* Renderer for Symfony2 instead of PHP templates.

My view of it is this:

- PHP templates are a great default since PHP is obviously always there,
but Twig seems to have become a first class citizen already, so it
wouldn't be too problematic, and it can always be removed if someone
doesn't like it.

- In my experience PHP templates encourage not-so-MVC-conscious
developers to put too much logic in their views, because it's very easy
to do so. Twig provides a context switch that help people make a
distinction, and also makes it harder/impossible to code complex logic
in templates.

- Twig with the custom tokens provides much more fluent and clean
interfaces to the template helpers, not to mention shorter. e.g.:

> {% route 'blog_post' with ['id': post.id] %}
>
> <?php echo $view['router']->generate('blog_post', array('id' =>
$post->id)) ?>

- The Twig syntax with dots to access properties and all looks and feels
like javascript, which imo is great for frontend developers to be sort
of in the same environment no matter if they work in templates or in js
code.

- On the downside, I guess Twig has a bit of a learning curve, but then
again people must learn the symfony "keywords" anyways, like
$view['router'], that aren't especially obvious to a non-sf developer.
So it's not like PHP templates are completely straightforward, and Twig
syntax is quite simple and well documented.

Thoughts?

Cheers

-- 
Jordi Boggiano
@seldaek :: http://seld.be/

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony developers" group.
To post to this group, send email to symfony-devs@googlegroups.com
To unsubscribe from this group, send email to
symfony-devs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-devs?hl=en

Reply via email to