[ZPT] Extending tal:condition, making metal:define
Evan Simpson
evan@digicool.com
Fri, 6 Apr 2001 16:23:00 -0500
From: "Guido van Rossum" <guido@digicool.com>
> I'm not sure about the semantics of "lazy:...". I thought that it was
> supposed to return None when the evaluation fails. But that would
> replace the element with nothing, not leave the default text in place
> (for that, you'd have to modify TALInterpreter, I believe).
The sort of thing I'm thinking of, call it "if:", would evaluate it's
expression and catch any traversal errors (traversal would be modified
to raise a new exception if a step failed in any way). On such an
error, it would return (or raise) doNothing. TALInterpreter would be
modified so that 'content', 'replace', and 'attributes' would do nothing
if they receive this signal. That way we could write:
<p tal:content="if:request/might_be_here">It isn't here.</p>
If "path:request/might_be_here" resolves, then its value replaces the
paragraph content, otherwise the default text remains. Likewise:
<a href="/default.html" tal:attributes="href if:here/goto">Go here</a>
"if::" could also be "optional:", or whatever.
Cheers,
Evan @ digicool