The way I see it, there are two main styles of templates.
- CakePHP style. You have 1 or more "layouts", and then a bunch of view pages that are inserted into the layout. The layout开发者_开发问答 is chosen in the code.
- Django style. There isn't really a concept of a "layout", but templates can include other templates. You generally write one template that serves as a layout, and then all the other templates just include this one.
What are the pros and cons of each?
To get us started...
Cake style means cleaner templates. No need to include the same layout over and over and over again. However, it also means that if you want to use a layout other than the default one, you have to specify it in the controller, which kind of breaks presentation and logic separation.
Another advantage is that you can use the same template in a different layout with no modifications or conditionals, or perhaps without a layout for use in an iframe.
精彩评论