[Petal] [IDEA] Hash with params

Evan Simpson evan at 4-am.com
Fri Sep 5 15:44:21 BST 2003


Steve Purkis wrote:
>     $key => <span petal:replace="some/hash $key">hash key</span>
> 
> A similar argument would apply to Arrays:
> 
>     list[$idx] = <span petal:replace="some/list $idx">hash key</span>

I'm not sure how well this would apply to Petal, but ZPTs are now 
officially growing a path syntax extension that specifically deals with 
these cases.  Examples of prefixed path segment usage are 
"some/hash/key:keystring" and "some/list/item:0".  Apart from a set of 
built-in prefixes, they are defined with tal:define="prefix <prefix> 
<expression>".  Generally, a prefix acts as either a function with two 
arguments or a namespace of single-argument functions.  The examples 
above are of the first sort -- they take the current traversal object 
and a key or integer argument.  An example of the second sort is the 
'standard' prefix, which in ZPTs is a namespace of standard formatting 
functions, as in "some/number/standard:thousands_commas".

Cheers,

Evan @ 4-am



More information about the Petal mailing list