[Zope-dev] Re: TALES idea: tuple unpacking

Evan Simpson evan@4-am.com
Tue, 29 Jul 2003 15:16:30 -0500


OK, I've checked in a sample implementation on "evan-pathprefix-branch". 
  It allows for registering prefixes with:

from Products.PageTemplates.PathPrefixes import registerSubPathPrefix
registerSubPathPrefix('call',  call_compiler, call_handler)

It includes an implementation of 'var:', 'call:', 'key:', 'item:', 
'attr:', and 'fmt:' with which the snippet:

<div tal:define="foo string:*foo*;
                  seq python:('arg', 3.4);
                  map python:{'*foo*': 'yes', 'keys': 'skeleton'}">
   <div tal:content="seq/item:0"></div>
   <div tal:content="seq/item:1/fmt:%.2f"></div>
   <div tal:content="template/attr:title"></div>
   <div tal:content="here/key:test3/title"></div>
   <div tal:content="structure foo/fmt:structured_text"></div>
   <div tal:content="map/key:keys"></div>
   <div tal:content="map/var:foo"></div>
</div>

...produces:

<div>
   <div>arg</div>
   <div>3.40</div>
   <div>My Title</div>
   <div>My Title</div>
   <div><p><em>foo</em></p>
</div>
   <div>skeleton</div>
   <div>yes</div>
</div>

You can try it out with the following commands in your 
$ZOPE/lib/python/Products/PageTemplates/ directory:

cvs -q up -r evan-pathprefix-branch PathPrefixes.py
cvs diff -r evan-pathprefix-branch-0 -r evan-pathprefix-branch \
   -u Expressions.py | patch

Cheers,

Evan @ 4-am