[Zope] building a Javascript array with TAL in ZPT
Chris Withers
chris at simplistix.co.uk
Wed Mar 16 04:53:08 EST 2005
Etienne Desgagné wrote:
> 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)
For better or for worse, ZPT's won't process anything inside a script tag.
I'd generate it using a python script:
js_template = '''
//whatever js you want ot be staticly generated
%s
'''
array = ','.join(container.reqZSQL3())
return js_template % array
...and then use them in your zpt as follows:
<script tal:content="here/my_js_generator"/>
cheers,
Chris
--
Simplistix - Content Management, Zope & Python Consulting
- http://www.simplistix.co.uk
More information about the Zope
mailing list