[ZPT] How can I place a semicolon (;) in a tal string?

Lynn Walton waltonl@franklin.edu
Fri, 18 Jan 2002 18:00:29 -0600


Did you try escaping it with another semicolon?

http://www.zope.org/Documentation/Articles/ZPT2 has a section that says:

Statements with Multiple Parts
If you need to set multiple attributes on a tag, you can't do it by placing multiple
tal:attributes statements on the tag, and splitting them across tags is
useless.

Both the tal:attributes and tal:define statements can have multiple parts in a single
statement. You separate the parts with semicolons (;), so any
semicolon appearing in an expression in one of these statements must be escaped by doubling it
(;;).

Lynn

> I try the following:
>
> in the header of a templatefile I define two string varaibles like so:
>
> <meta  tal:define="grabbdefault string:'menopause';grabbdefault2
> string:'diagnostik';" tal:replace="nothing">
>
> in the bodytag I want to use it like so:
>
> <body tal:attributes="onload python:'grabbDefault=%s;grabbDefault2=%s;' %
> (grabbdefault, grabbdefault2)">
>
> When I try to save this, I get an error:
>
> <!-- Page Template Diagnostics
>  Compilation failed
>  TAL.TALDefs.TALError: Bad syntax in attributes:'grabbDefault2=%s'