[Zope] Slicing strings in ZPT

Chad Nantais cnantais@rednaxel.com
Thu, 28 Feb 2002 14:05:50 -0500


I want to slice a phone number inside of a page template. I am currently
using the following syntax to define the area code portion so it can be used
to prefil a text input box:

<td align="left" valign="top" tal:define="area python:item.home_phone[:2];
pref python:item.home_phone[4:6]; suff python:item.home_phone[8:]">

I get the following template error.

<!-- Page Template Diagnostics
 Compilation failed
 TAL.TALDefs.TALError: invalid define syntax: 'area', at line 70, column 7
-->

I think it's because the colon in the slice directive is confusing tal. How
do I get the slice functionality without breaking tal? Is there an escape
sequence or something?

Thx,

Chad