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

Evan Simpson evan@zope.com
Fri, 18 Jan 2002 12:36:08 -0500


Robert Rottermann wrote:
> <meta  tal:define="grabbdefault string:'menopause';grabbdefault2
> string:'diagnostik';" tal:replace="nothing">
> 
> <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'
> -->

Both tal:define and tal:attributes require you to double semicolons that 
are not being used to separate definitions or attribute assignments.  In 
  other words, you should write:

<meta tal:define="grabbdefault string:'menopause';grabbdefault2
string:'diagnostik'" tal:replace="nothing">

<body tal:attributes="onload python:'grabbDefault=%s;;grabbDefault2=%s;;' %
(grabbdefault, grabbdefault2)">

The body can also be written:

<body tal:attributes="onload 
string:grabbDefault=$grabbDefault;;grabbDefault2=$grabbDefault2;;'>

Cheers,

Evan @ Zope