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.