Re: [Zope] The XML-dtml notation "&dtml-variable;"
Christopher Petrilli <petrilli@digicool.com> said:
On 11/4/99 11:31 AM, Michel Pelletier at michel@digicool.com wrote:
Johan Carlsson wrote:
But, isn't there a way to supply a default value (if the variable lookup fails)?
Something like &dtml-variable default-value;
I think that would be stretching the semantics of <dtml-var> a bit beyond where they should go. Just wrap the entity in a <dtml-if> and test for the variable existence beforehand. Longer, but much more clear.
Would something like this be more palatable?
<dtml-var foo default="Empty">
How is this different from the following? <dtml-var foo null="default-value"> Drew
At 4:05 pm +0000 4/11/99, Andrew wrote:
Would something like this be more palatable?
<dtml-var foo default="Empty">
How is this different from the following?
<dtml-var foo null="default-value">
Because the null part is used if the variable already exists, just that it's *value* is None. The new syntax would make <dtml-var spam default="0"> be equivalent to <dtml-if spam> ...do stuff <dtml-else> <dtml-call "REQUEST.set('spam', '0')"> </dtml-if> ie would *create* a variable and set it to a sensible default. Note that if you try your line of code in a DTML object when foo hasn't been set, you'll get a traceback (unless you're using try tags) Least ways, that's how *I've* interpreted it! :) hth tone ------ Dr Tony McDonald, FMCC, Networked Learning Environments Project http://nle.ncl.ac.uk/ The Medical School, Newcastle University Tel: +44 191 222 5888 Fingerprint: 3450 876D FA41 B926 D3DD F8C3 F2D0 C3B9 8B38 18A2
participants (2)
-
Andrew -
Tony McDonald