On Sat, May 17, 2008 at 11:30 PM, James Bennett <[EMAIL PROTECTED]> wrote: > The impression I get is that a lot of people rely on silent *variable* > failure, but very few rely on silent *tag* failure. In fact, most > real-world custom template tags I've seen are wired up to raise errors > quite loudly, and the few times I've tried to write tags which fail > silently it's been a laborious process that results in much more > brittle code.
Well said. I can't see making ``{{ foo.bar.baz }}`` fail loudly -- it's just too big a change. It especially sucks when ``foo`` or ``bar`` is a dynamically-constructed dictionary with variable keys. I think taking a close look at built-in *tags*, though, is a good idea -- in general, tags should fail loudly. There are exceptions, of course; ``{% if dict.somekey %}`` is a common idiom which translates to something like ``if dict.has_key('somekey') and dict.somekey`` -- this is good. A final note: if you want loud variable failures, it's a pretty trivial task to write a template tag that echoes a variable or raises an exception; you could then use ``{% require foo.bar.baz %}`` instead of ``{{ foo.bar.baz }}``. I'll leave the actual implementation up to the intrepid reader; it's just a few lines of code. Jacob --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-developers?hl=en -~----------~----~----~----~------~----~------~--~---