tags:

views:

26

answers:

2

What's the point of using template structure like this:

templates/
    app/
        article_view.html # or view_article.html
        category_view.html

vs

templates/
    app/
        article/
            view.html
        category/
            view.html

It's easier to find particular template with second approach, but I almost don't see any apps using it. Why?

+1  A: 

This depends on the scale of the project; a small-scale thingie could be more easy to handle with the first approach, while a project with several hundred template files could use a better folder structure, i.e. the second approach

Gabi Purcaru
Gabi: agreed -- I much prefer to flatten directory structures as much as possible. in his second example, he has two files named 'view.html', which will most likely be a source of confusion whenever he has to deal with these files w/o the context of the immediate hierarchy.
fish2000
A: 

Generally speaking, templates are associated with views rather than models. A view pulls in one or more models as needed, then renders the appropriate template. Since an app usually consolidates views in one file, the template to app correspondence works well enough.

ars