[ZPT] javascript

Harry Wilkinson harryw@nipltd.com
Fri, 12 Apr 2002 16:16:06 +0100


On Friday 12 April 2002 3:45 pm, Florent Guillaume wrote:
> Harry Wilkinson  <harryw@nipltd.com> wrote:
> > The <script> and <style> tags are specifically excluded from ZPT because
> > they contain data that is supposed to be delivered directly to the
> > application without parsing.  So basically, you can't make your scripts
> > dynamic by embedding ZPT presentation code in them, although I have to
> > say I'd like to be able to.
> >
> > If you need your scripts to be dynamic, I suggest using a Python script
> > to generate the Javascript code.
>
> Just rewrite
>         <script>
> as
>         <span tal:replace="structure python:'&lt;script:&gt;'" />
> or something like that (completely untested !!).
> And same for </script>.
>
> Florent

Hey, good idea! :)  I shoulda thought of that ;)

I just tried it out, and this works:

<div tal:replace="structure python:'<script>'">a script tag</div>

<tal:comment replace="nothing"> your script goes here </tal:comment>

<div tal:replace="structure python:'</script>'">a /script tag</div>