[ZPT] Path expression
Harry Wilkinson
harryw@nipltd.com
Thu, 18 Apr 2002 15:59:20 +0100
On Thursday 18 April 2002 3:49 pm, Tom Deprez wrote:
> Hi,
>
> I've tried every possibility from the Zope Book examples, but I can't get
> it to work.
>
> Basicly I need to get a variable out of the namespace and if it doesn't
> exists, nothing must happen as in
>
> tal:content="here/myvar | nothing;"
>
> however, myvar is dynamic, does I should use:
>
> tal:content="python:path('here/%s'%myvar')"
>
> but the problem lies in the fact that when myvar doesn't exists in the
> namespace, I get an error, which may not happen.
>
> I tried tal:content="python:path('here/%s' % myvar') | nothing", but this
> still gives an error when the variable doesn't exist
>
> Is there a way to get this working with a valid path expression?
>
> Thanks in advance,
> Tom
>
You could stick a tal:condition attibute on the tag that looks something like:
tal:condition="exists:here/myvar"
That's probably best used along with a tal:replace rather than a tal:content
though, so you may want to change things around a bit.
Harry