On 24 Nov 2005, at 02:53, Adrian Holovaty wrote:
Then those template tags would depend on DjangoContext -- that couples DjangoContext to the template tags, which is bad. :-/
It would certainly be bad if all template tags were coupled to DjangoContext, and it would be bad if any of the core template tags were coupled to it - but I don't see the harm in allowing people to write custom template tags that are coupled to the DjangoContext (and through it the request object) if they want to. It's a major convenience feature for some applications. Here are a few potential template tags off the top of my head that are impossible at the moment (without extra view code) but could be enabled by access to the request:
{% counter %} - a 1996 era counter showing how many times that specific page has been loaded {% context_specific_ads %} - ad banner code that changes depending on the URL {% browser_specific IE+Safari %} - Code only shown to IE and Safari (yes, this is a horrible idea) {% one_off_ad %} - ad that is shown once, then blocked from future display with a cookie
None of the above are hugely compelling, but they do demonstrate the extra flexibility access to the request object gives template authors. Again, I'm not advocating coupling the template system and response object in all cases, but it would be great if the option was there for custom tag authors if they needed it.
Cheers, Simon
