You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by Neil Gunton <ne...@nilspace.com> on 2001/12/19 21:46:26 UTC

2.0b5 error: Nested tags handled incorrectly?

I have the following code snippet, which is being migrated from 1.3.4 to
2.0b5:

<DL>
[- $prev_page_id = 0 -]
[$ while $figure = $query->fetchrow_hashref() $]
   [$ if $figure->{page_id} != $prev_page_id $]
      [$ if $prev_page_id $]
	 </UL>           <---------- ERROR LINE
	 <P>
      [$ endif $]
      <DT><H3>[- $subs->contents_entry ($figure) -]</H3>
      <UL>
   [$ endif $]
   <LI>Blah blah blah
   [- $prev_page_id = $figure->{page_id} -]
[$ endwhile $]
[$ if $prev_page_id $]
   </UL>
[$ endif $]
</DL>

This page works fine in 1.3.4, but fails with 2.0b5:

[2422]ERR: 49: index.html(32): Endtag '/ul' doesn't match starttag 'dl'

The line in question is the first </UL>, which is out of sequence in the
source code but will be placed in sequence in the output. The code does
compile ok when I munge the code to put all tags in "correct" nested
sequence. I realize that 2.0b5 requires nesting to be correct, but
surely this only applies to the final output, not to the source code?
The conditionals and loops such as what I have above will often contain
situations such as this.

I have checked the output from the page under 1.3.4, and the HTML
appears to be formatted correctly.

Is this a bug, or am I doing something wrong here?

TIA

-Neil

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: 2.0b5 error: Nested tags handled incorrectly?

Posted by Neil Gunton <ne...@nilspace.com>.
Gerald Richter wrote:
> 
> No it applies to the source! Otherwise Embperl is not able to create valid
> Perl code out of it.
> 

Ok. I realize that this is an architectural/design decision, but my gut
feeling is that it's counter-intuitive to the average programmer. Here's
why: The Embperl model is fundamentally about dynamically creating HTML.
This obviously means conditional code and loops. A programmer does not
intuitively expect *conditional* HTML code to "count" in a syntactic
sense before it is actually executed. For example, you may have several
conditionals inside a loop, each of which contains some kind of HTML
fragment. Each of these conditional fragments may contain repeated
instances of the same HTML fragment, in a slightly different format. Any
interesting (i.e. non-trivial) code will have this kind of thing. Why
should each case of conditional HTML which contains (e.g.) a <UL> or
</UL> tag be counted in the HTML syntax checking, even though it's not
actually included in the final page? This kinda negates the whole
convenience of having conditional code.

I know that you can disable the Embperl syntax checking with the
directive you specified, but this introduces additional overhead and
potential for error (since you need to remember to turn it back on again
after). Besides, it would surely be nice to be notified of errors in
your HTML, *especially* in complex cases where you need to build some
kind of nested lists by using loops and conditionals. Surely the
checking of HTML syntax should be on the code which is actually
generated, not on the source.

Just my two cents, as I said before I realize it's an architectural
decision, and might even be extremely hard to implement it this way. Not
a huge deal but I thought it worth mentioning...

All the best

-Neil

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: 2.0b5 error: Nested tags handled incorrectly?

Posted by Gerald Richter <ri...@ecos.de>.
>
> This page works fine in 1.3.4, but fails with 2.0b5:
>
> [2422]ERR: 49: index.html(32): Endtag '/ul' doesn't match starttag 'dl'
>
> The line in question is the first </UL>, which is out of sequence in the
> source code but will be placed in sequence in the output. The code does
> compile ok when I munge the code to put all tags in "correct" nested
> sequence. I realize that 2.0b5 requires nesting to be correct, but
> surely this only applies to the final output, not to the source code?

No it applies to the source! Otherwise Embperl is not able to create valid
Perl code out of it.

But only HTML tags that Embperl recogizes must be in corect order. The UL
and DL tags are recogized in case they contain a dynamic table.

> The conditionals and loops such as what I have above will often contain
> situations such as this.
>

You can turn parsing html tag temporarily off to work around this. Write

[$ syntax EmbperlBlocks $]

to only parse [ ] blocks and

[$ syntax Embperl $]

to again parse everything.

> I have checked the output from the page under 1.3.4, and the HTML
> appears to be formatted correctly.
>

That's because 1.3 and 2.0 creates totaly different Perl code. The benefit
of the 2.0 way, is that it is much faster and that [* *] blocks works
correctly.

> Is this a bug, or am I doing something wrong here?
>

This is not a bug of Embperl, but by design. It's a incompatible change from
1.x to 2.x

Gerald

-------------------------------------------------------------
Gerald Richter    ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

Post:       Tulpenstrasse 5         D-55276 Dienheim b. Mainz
E-Mail:     richter@ecos.de         Voice:    +49 6133 925131
WWW:        http://www.ecos.de      Fax:      +49 6133 925152
-------------------------------------------------------------



---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org