views:

57

answers:

1

What's a good way to handle commonly occurring subsections of templates? For example, there is a sub-header section that's used across 4 different pages. The pages are different enough to not work well with template inheritance (ie. "extends" doesn't fit well).

Is "include" the recommended method here? It feels a bit heavyweight, requiring each subsection or snippet to be in its own file. Are there any performance issues in using include or is it smart about forming template from the subsections (ie. if I make extensive use of it, do I pay any penalties)?

I think what I'm looking for is something like template tags, but without the programming - a simple way to create a library of html template tags I can sprinkle in other templates.

+1  A: 

I don't think there's anything bad about using includes in templates when it comes to performance! If you want a more detailled analysis, give django-debug-toolbar a try, because it shows you also how much time/calls are spent where when it comes to templates!
http://github.com/robhudson/django-debug-toolbar

Otherwise, where suitable "extending" of templates if for sure a good practice, can safe you lots of work!

lazerscience