On 1/13/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > I definitely understand why business logic should be kept out of the > template; I don't see why adding AND/OR support is any worse than > having if/if not/ifequal/ifnotequal/for. > > During the Snakes & Rubies talk it was mentioned that many times there > has to be logic in the template, but just because it is logic does not > necessarily make it business logic.
This is true. The logic in Django templates is intentionally simple in an attempt to enforce exactly this separation. For example, the templates allow you to write a template that says (in effect): if subscriber print X, else print Y. What does "subscriber" mean in this context? That's a business logic decision, which should be able to be changed independent of the way that a "subscriber" is displayed. If the templates allowed more complex logic, template designers might be tempted to write a template that reads "if last_payment.before(today - 1 year) and not admin". However, this encodes a business logic decision in the template. Since the template language does not allow complex queries, the designer cannot do this, so they must establish their high level design requirements, and ask the view developer to provide the appropriate context values - thereby keeping business logic in the view, where it belongs. Russ Magee %-)