"As simple as possible, but no simpler."
I have a lot of respect for what the Django guys have done. I actually really like a lot of Django. However, having tried it, I find the templating engine to be elegant, but too simple. What frustrates me most is the lack of functions. In my first programming class, I learned how to use functions for code reuse. DRY applies even to HTML. At my company, even the "template authors" know how to create a function to avoid code duplication. Nor is the "include" or "block" statement a suitable replacement--functions have parameters. Different arguments lead to different results. This is necessary functionality. Also, functions should support recursion. I learned in my second programming class how to think recursively, and every once in a while it really comes in handy (for instance, when you're writing a bulletin board application with a hierarchy of messages).
When I was using Django templates, I really felt like my hands were tied. I don't think lack of functions improves security. I don't think custom tags are always a suitable replacement--I'm talking about simple HTML reuse. Please forgive my boldness, but I don't think I should have to live without functions just because a template writer working at some other company doesn't understand them.
Next, I think I'll try out using Django with Cheetah. So far, Cheetah has always met my needs exceedingly well. Hopefully, I can get it to fit in smoothly, maintaining Django's overall elegant feel.
I have a lot of respect for what the Django guys have done. I actually really like a lot of Django. However, having tried it, I find the templating engine to be elegant, but too simple. What frustrates me most is the lack of functions. In my first programming class, I learned how to use functions for code reuse. DRY applies even to HTML. At my company, even the "template authors" know how to create a function to avoid code duplication. Nor is the "include" or "block" statement a suitable replacement--functions have parameters. Different arguments lead to different results. This is necessary functionality. Also, functions should support recursion. I learned in my second programming class how to think recursively, and every once in a while it really comes in handy (for instance, when you're writing a bulletin board application with a hierarchy of messages).
When I was using Django templates, I really felt like my hands were tied. I don't think lack of functions improves security. I don't think custom tags are always a suitable replacement--I'm talking about simple HTML reuse. Please forgive my boldness, but I don't think I should have to live without functions just because a template writer working at some other company doesn't understand them.
Next, I think I'll try out using Django with Cheetah. So far, Cheetah has always met my needs exceedingly well. Hopefully, I can get it to fit in smoothly, maintaining Django's overall elegant feel.
Comments
You might want to try using Myghty with Django... It looks like Myghty gives you the most freedom to define those functions in those templates like you want to. I say "looks like", though, because I haven't used, just skimmed the docs... If Myghty is "just a python library" like Cheetah is, then the integration of Django and Myghty might be pretty easy. So check out Myghty and let me know if I'm way wrong on this.
Django does have a quite flexible template language - you only need to accept that to do more complex work, you either precompute stuff in the view function or build custom template tags.
I thought about switching to Cheetah for a while, but I enjoy Django and I am still doing things the Django way.
However I have started to create my own library of custom tags that are more robust than the one Django offers.
So for your board problem, I recommend you try that approach rather than changing the template engine; rather than using render_to_response, do the calling and recursing in python, and make calls into the template engine to turn your data into html snippets.
I felt the same on my first contacts with those templates. But then I had an epiphany. Actually trying to develop with Django made me move all my logic out of the templates and into python (into the view), which is something I have been wanting to do for years.
I hear what you're saying, but I truly believe that even template authors should not be exempt from DRY.