Philipp von Weitershausen wrote:
I agree that it is 'yucky', but I have to disagree with your proposed
solution. I would rather suggest making TALES aware of integer indexes
for sequences. Example::

  <tal:block repeat="user_files here/listFilesByUser">
    User: <tal:dummy replace="user_files/0" />
    File: <tal:dummy replace="user_files/1" />

Here's the way I'd like to spell it:

  <div tal:repeat="user_files here/listFilesByUser">
    User: <span tal:replace="user_files/int:0" />
    File: <span tal:replace="user_files/int:1" />

Literally, "user_files/int:0" says "get item 0 of user_files, interpreting '0' as an integer". Technically, this could be interpreted as "get the attribute named 0 or item 0", but an attribute name must be a string, so implicitly it really just says "get item 0".

We've come up with a number of generally useful prefixes, BTW. Off the top of my head:

call:   -- Call a named method
int:    -- Look up an item by index
format: -- Perform simple formatting operations like "format:money"
zope:   -- Access a big Zope API

It sure would be nice to have these prefixes, both in Zope 2 and Zope 3.


Zope-Dev maillist - [EMAIL PROTECTED]
** No cross posts or HTML encoding! **
(Related lists - )

Reply via email to