[ZPT] Using variables in path expressions

Brent M Hendricks brent@valinor.waldenweb.com
Thu, 7 Jun 2001 21:59:54 -0500


On Sat, Jun 02, 2001 at 03:06:42PM -0500, Evan Simpson wrote:
> 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>
> 
> 
> 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"

Hmm.  Is there a technical reason why it uses a different syntax here?
In the interest of consistency, I'd think we would want to use ${} here
too.

And since I'm already nagging you about notation (<grin>), I might as
well ask: How hard would it be to allow paths embedded in paths?  I
would think you could just pass the expression through the "string:"
processor first to expand the variables and then pass the resultant
string into the "path:" processor.

Perhaps this is just my naive view of things and I should really just
shut up and dig into the code :)

--Brent


-------------------------------------------------------------------------

"The programmer, like the poet, works only slightly removed from pure
 thought-stuff.  He builds his castles in the air, from air, creating
 by exertion of the imagination.  Few media of creation are so
 flexible, so easy to polish and rework, so readily capable of
 realizing grand conceptual structures."
                        -- Frederick Brooks, Jr., The Mythical Man Month