phpsymfony1coding-stylephptal

Cleanup Symfonys View Templates


I'm evaluating the PHP webframework: Symfony for a project. Everything is quite well organized so far, except for the view templates which suffer from an unreadable/error prone mix of html and php (I was trying to adapt the views to use clean urls and that just turned out to be an exercise in "spot the delimiters").

Is there any methods of cleaning up the view templates so that the php code is moved to the Model or an intermediate Controller?

I know of the existence of PHPTAL, but because of the sheer size of Symfony I have no idea where to even start integrating somethign like PHPTAL into the framework.


Solution

  • i think it's the symfony way to combine PHP and HTML in templates. if you prefer using another language for writing templates you should integrate one of the PHP templates engines into your symfony project. there are a lot of template engines other than PHPTAL, and there are already symfony plugins for some of them on symfony plugins page (examples are Smarty, XSLT, OPT and Haml)