[Zope] RE: Dynamically generating JavaScript
Andy Yates
andy at nnu.com
Mon Feb 14 11:37:43 EST 2005
Yes, you are right that works fine and is cleaner. My point is that
Zope does not seem to render tal statements between <script> tags. They
get ignored.
This works
<script type="text/javascript" tal:content="here/myscript_js"></script>
but this does not.
<script type="text/javascript" >
<tal:block tal:content="here/myscript_js" />
</script>
Andy
> -----Original Message-----
> From: zope-bounces at zope.org [mailto:zope-bounces at zope.org] On Behalf
Of Duncan Booth
> Sent: Monday, February 14, 2005 9:04 AM
> To: zope at zope.org
> Subject: [Zope] RE: Dynamically generating JavaScript
>
> Andy Yates wrote:
>
> > When I've had to include dynamic javascript I write a python method
that
> > prints the whole script block and then call that from a tal:block.
> >
> ><tal:block tal:replace="structure python: here.myscript_js()" />
> >
> > myscript_js would look like this
> >
> > print """<script>
> > var1 = 1;
> > var2 = 2;
> > var3 = 3;
> ></script>"""
> >
> > return printed
> >
>
> Wouldn't it make more sense to do:
>
> <script type="text/javascript"
tal:content="here/myscript_js"></script>
>
> and just have myscript_js print the Javascript without the enclosing
script
> tags?
>
> for i in range(1,4):
> print "var%d = %d" % (i, i)
>
> return printed
>
> Or even better, if your script contents don't depend on values from
the
> current request use:
>
> <script type="text/javascript" src="myscript_js"></script>
>
> which keeps the Javascript entirely outside the html so you don't have
to
> worry about embedded angle brackets.
>
> _______________________________________________
> Zope maillist - Zope at zope.org
> http://mail.zope.org/mailman/listinfo/zope
> ** No cross posts or HTML encoding! **
> (Related lists -
> http://mail.zope.org/mailman/listinfo/zope-announce
> http://mail.zope.org/mailman/listinfo/zope-dev )
More information about the Zope
mailing list