[ZPT] Using variables in path expressions

Evan Simpson evan@digicool.com
Sat, 2 Jun 2001 15:06:42 -0500


From: "Brent M Hendricks" <brent@valinor.waldenweb.com>
> Is there a way to get variable substitutions in path expressions the
> way we have them in string expressions?

> <div tal:repeat="item here/queryIds">
>   <span tal:content="here/subfolder/${item/id}/method" />
> </div>

There is undocumented support for this.  We were holding off on making
it part of the spec, waiting to see whether it's really needed.
Technically, it's not, since you can write:

tal:content="python:path('here/subfolder/%s/method' % item.id)"

I admit that this is a little messy.  The undocumented capability does
not allow paths (like 'item/id'), only raw variable names.  The name
must contain either a string or a sequence of strings, which will be
interpolated as one or more entire path segments:

tal:define="item_id item/id"
tal:content="here/subfolder/?item_id/method"

Cheers,

Evan @ digicool