[Zope] building a Javascript array with TAL in ZPT

bruno modulix bruno at modulix.org
Mon Mar 14 08:57:56 EST 2005


Etienne Desgagné wrote:
> Hi everyone,
> 
>     I need to buid a javascript array of this form:
> 
> var theArray = new
> Array("123|Beth","543|John","234|Ben","43|Leia","76|Steven","45|Rebecca","7686|Travis","3456|Kirk");
> 
> but by using TAL in a ZPT. The values come from a ZSQL method. It could look
> like this:
> 
> var theArray = new Array(
>    <span tal:repeat="array_elt container/reqZSQL3" tal:omit-tag="">
>        <span tal:replace="array_elt">1</span><span
> tal:condition="not:repeat/array_elt/end" tal:omit-tag="">, </span>
>    </span>);
> 
> but this is not working. (the ZSQL method contain the two columns of value)
> 
> Someone have an idea?
> 

ZPT is meant to generate [xml | (x)html]. Not css, javascripts, SQL or 
anything else (note that ZSQL methods use dtml as templating).

For what you want, you may use a dtml method (first choice IMHO for 
non-html templating in Zope), or a python script (if the logic is too 
complex for dtml or if you don't want to learn dtml) that you call from 
the ZPT.

My 2 cents...
-- 
Bruno Desthuilliers
Développeur
bruno at modulix.org


More information about the Zope mailing list