[Bese-devel] [ucw] 0.2.0pre0

Marco Baringer mb at bese.it
Mon Feb 23 20:11:16 UTC 2004


Lunedì, 23 feb 2004, alle 20:44 Europe/Rome, Le grand pinguin ha 
scritto:

>  I'd like to have the TAL transformer substitute some attribute 
> values, i.e.
>
>   <li tal:dolist='$resources'><a href='$url'><tal 
> tal:replace='$name'></a></li>
>
>   All i get is href='$rl' -- is this not yet implemented? Who is 
> eating the 'u'?

[the #\u getting removed is a bug]

[This is an as yet un documented bit of TAL:]

You can put lisp expressions in tal files in two places:

1) tal: or ucw: attributes (like tal:dolist or ucw:accessor), in these 
cases the value of the attribute is really just lisp code with #\$ 
bound to a read macro.

2) in every other attribute (like your href above) we use this syntax: 
everything in the attribute is concatenade together, if we find a 
${...} then the result of elavuating ... is concatenated, if we find a 
@{...} then every element of the list returned by ... is concatended 
individually. In both cases ... is read with the usual #\$ read macro. 
examples (assuming url is bound to "ucw" is the enviroment):

A) <a href="${$url}" ==> <a href="ucw"

B) <a href="@{(list :thing $url)}" ==> <a href=":THINGucw"

C) <a href="before ${$url} after" ==> <a href="before ucw after"

D) <a href="before @{(list :thing $url)} after" ==> <a href="before 
THINGucw after"

How do you know which syntax to use? Every "normal" html tag uses 
syntax 2, every "control flow" or otherwise slightly more complex ucw 
or tal attribute uses syntax 1. I would like to unify these two 
syntaxes, however in cretain cases I want to be able to do what I did 
in (C) above, and in other cases I want the attributes to be 
interpreted as lisp code; I don't know how to unify these two needs 
into a single syntax.

So, i'd suggest writing you example as:

<li tal:dolist="$resources">
   <a href="${$url}" tal:content="$name">NAME</a>
</li>

--
Marco
Ring the bells that still can ring.
Forget the perfect offering.
There is a crack in everything.
That's how the light gets in.
	-Leonard Cohen





More information about the bese-devel mailing list