[Grok-dev] Re: best way to dynamically create javascript using ZPT
Noah Gift
noah.gift at gmail.com
Thu Jan 10 03:29:19 EST 2008
On Jan 10, 2008, at 2:51 AM, Godefroid Chapelle wrote:
> 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 ;-)
I will need to look into megrok.kss, as I agree unless you need to
deal with a Javascript API, javascript can get pretty messy in a
template.
>
> --
> Godefroid Chapelle (aka __gotcha) http://bubblenet.be
http://noahgift.com [Python+Grok+AJAX+Mashup]
More information about the Grok-dev
mailing list