[Grok-dev] Re: best way to dynamically create javascript using ZPT
Godefroid Chapelle
gotcha at bubblenet.be
Thu Jan 10 02:51:33 EST 2008
Noah Gift wrote:
> In doing our screencast tonight, we wanted to dynamically create
> javascript, and ran into a problem. What is the best method, or
> preferred method to deal with javascript embedded into a template. It
> appears that you cannot replace the contents of anything inside:
>
> <script type="text/javascript">
>
> using tal expressions. we were attempting to pass attributes from ZODB
> and then create dynamic javascript with them. I am thinking this is
> perhaps not allowed by design? If so, what is the better way to talk to
> javascript for Grok, and pass things to javascript functions.
>
> Noah
I would compute the tag and the contained javascript in a view method
(where you can use python string interpolation for instance).
You should then be able to do
<div tal:replace="structure view/myScriptTag" />
( Rather, I would avoid use JS itself and use megrok.kss ;-)
--
Godefroid Chapelle (aka __gotcha) http://bubblenet.be
More information about the Grok-dev
mailing list