[Zope] Dynamically generating JavaScript
    Hong Yaun 
    hongyuan at homemaster.cn
       
    Mon Feb 14 09:31:05 EST 2005
    
    
  
I have a page template within with I would like to embed some 
dynamically generated JavaScript. Say the following sample snippet:
<script>
var1 = 1;
var2 = 2;
var3 = 3;
</script>
The 'obvious' approach I came up with is the follow zpt code:
<script>
<tal:block tal:repeat="i python:range(1,4,1)">
var<span tal:replace="i"/> = <span tal:replace="i"/>
</tal:block>
</script>
However, this code doesn't even compile correctly, with the error:
TAL.HTMLTALParser.NestingError: Open tag <script> does not match close 
tag </tal:block>
If instead I replace the <script> and </script> tags with things like 
<html> and </html>, the code compiles. Obviously, I am missing a very 
important point about the way zpt works, but I can't find what. Maybe it 
is not suitable for this kind of task and I shall use DTML or 
PythonScript instead?
Any hint would be appreciated.
Best Regards
Hong Yuan
    
    
More information about the Zope
mailing list