[Zope] Re: ZPT changing javascript (HOW?) - Easy with DTML

Evan Simpson evan@4-am.com
Thu, 03 Oct 2002 14:54:39 -0500


Mike Renfro wrote:
> I'd be surprised if it parsed fine; if so, I was unaware that <span>
> didn't require a </span> tag. How about replacing:

<script> and <style> elements contain text that is not parsed for tags. 
  The only way to make this text dynamic is with tal:content, in either 
of the two following ways:

<script tal:content="structure string:
   var x = $x;
   x = x + 1;
   ...
"></script>

<script tal:content="structure path/to/dtml_or_other_method"></script>

In other words, big honking string expression or another object that 
generates the text.  Note that if all you're doing is setting up script 
variables, you can split the script like so:

<script tal:content="structure string:
   var x = $x;
   var foo = ${template/id};
"></script>
<script>
   x = x + 1;
   ...etc...
</script>

Cheers,

Evan @ 4-am