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

Christopher N. Deckard cnd@ecn.purdue.edu
Thu, 3 Oct 2002 14:46:54 -0500


On Thu, 3 Oct 2002 13:54:24 -0500, Mike Renfro spoke forth:

> On Thu, Oct 03, 2002 at 12:20:14PM -0500, Christopher N. Deckard
> wrote:
> > Well, I tried the following, but it didn't work.  It parses just
> > fine.  Are "script" tags ignored when the PT is rendered?  I
> > could understand why.  
> 
> I'd be surprised if it parsed fine; if so, I was unaware that
> <span> didn't require a </span> tag. How about replacing:
> 
>   username = <span tal:replace="USER_NAME"/>;

That's what the '/' at the end of the tag is for.  Shorthand HTML I
guess.  It's valid html, but in some cases just less readable.

> with
> 
>   username = <span tal:replace="USER_NAME">username</span>;
> 
> and then doing similarly for the other variables?

And what's weird is the <span></span> format seems to have parsing
issues when between 'script' tags.  The following does not seem to
parse properly:

<html>
<head></head>
<body>

<script tal:define="USER_NAME user/getUserName"
        type="text/javascript">  
function connect()
  {
    username = <span tal:replace="USER_NAME">username</span>;
  }
</script>

</body>
</html>

Error Message:
Compilation failed
TAL.HTMLTALParser.NestingError: Open tags <html>, <body>, <script>
do not match close tag </span>, at line 8, column 54

Getting rid of the 'script' tags fixes it, but does not solve the
original problem.

-Chris