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

Charlie Reiman creiman@kefta.com
Thu, 3 Oct 2002 14:10:15 -0700


Speaking here as someone who knows XHTML and XML but not ZPT: This probably
won't work. <script> isn't supposed to contain other tags. Go read the FAQ
on the XHTML validator for some idea of how javascript and XHTML just don't
mix well. Consider moving your script into python or dtml.

Also, you shouldn't do this for empty elements:

<sometag/>

You should always place a space in there:

<sometag />

Again, see the XHTML spec, validator, and validator FAQ.


> -----Original Message-----
> From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of
> Christopher N. Deckard
> Sent: Thursday, October 03, 2002 12:47 PM
> To: Mike Renfro
> Cc: zope@zope.org
> Subject: Re: [Zope] ZPT changing javascript (HOW?) - Easy with DTML
>
>
> 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