[Zope] ZPT changing javascript (HOW?) - Easy with DTML
sean.upton@uniontrib.com
sean.upton@uniontrib.com
Fri, 04 Oct 2002 08:23:55 -0700
Perhaps I'm late to this conversation, so I might be misunderstanding the
context, but I have another ZTP script tag problem... In the HTML 3.2/4.0
specs, stuff in script tags is implicitly CDATA in HTML (though not in
XHTML). ZPT does not respect this, so JavaScript with '<' or '>' inside JS
string literals causes problems with parsing the PT. IMHO, this is a bug
unless the PT in question is set explicitly to XML? Has anyone else
encountered this? Does anyone mind if I file this in the collector?
Eaxmple would likely fail ZPT parsing:
<script>
document.write('<a href="' + somevar + '">" + someothervar +
'</a>');
</script>
Thoughts?
Sean
-----Original Message-----
From: Charlie Reiman [mailto:creiman@kefta.com]
Sent: Thursday, October 03, 2002 2:10 PM
To: Christopher N. Deckard; Mike Renfro
Cc: zope@zope.org
Subject: RE: [Zope] ZPT changing javascript (HOW?) - Easy with DTML
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
_______________________________________________
Zope maillist - Zope@zope.org
http://lists.zope.org/mailman/listinfo/zope
** No cross posts or HTML encoding! **
(Related lists -
http://lists.zope.org/mailman/listinfo/zope-announce
http://lists.zope.org/mailman/listinfo/zope-dev )