[phplib] odd behaviour when parse()-ing a block From: Dima Nemchenko (Dima.Nemchenko <email protected>)
Date: 06/04/01

Hi all,

I wonder if anyone has had this same problem and, if so, could explain it
to me. I'm using PHP Version 4.0.5 and PHPLib 7.2b, though I've modified
template.inc:

     diff -uNr ~/template.inc ~/php/template.inc
     --- /home/myhomepageonline/template.inc Mon Jun 4 14:04:33 2001
     +++ /home/myhomepageonline/php/template.inc Mon Jun 4
     14:02:43 2001
     @@ -106,7 +106,10 @@
          $str = $this->get_var($parent);
          $reg = "/<!--\s+BEGIN $handle\s+-->(.*)<!--\s+END
     $handle\s+-->/sm";
          preg_match_all($reg, $str, $m);
     - $str = preg_replace($reg, "{$name}", $str);
     +# $str = preg_replace($reg, "{$name}", $str);
     +# 2001-05-30, dn <email protected>
     +# q.v.
     http://www.phpbuilder.com/mail/phplib-list/2000071/0108.php
     + $str = preg_replace($reg, "{"."$name}", $str);
          $this->set_var($handle, $m[1][0]);
          $this->set_var($parent, $str);
        }

I've got a block in the main template, which is parsed twice, with two
different templates substituted for the block item. Everything works ok,
but...

Looking at the source, I see that all the HTML "entities" from the second
template, like "&lt;" and "&nbspl", have been translated into "plain" ASCII
characters, like "<" and " ". This doesn't happen in the first template, or
if I parse without appending.

Has anyone else seen this?

Thanks in advance for all your time,

--

:D_ima Dima Nemchenko <Dima.Nemchenko <email protected>>

"Open source code is like lobster--most people who haven't tried it don't like the way it looks. But those who try it, love it."