Connecting Tech Pros Worldwide Forums | Help | Site Map

Re: New template engine - retry

Sjoerd
Guest
 
Posts: n/a
#1: Aug 6 '08
On 6 aug, 10:53, Egbert Teeselink <skreb...@gmail.comwrote:
Quote:
"mplate, a PHP template engine that Doesn't Suck(tm)" (or at least,
that's what I hope)
I got this:
Parse error: syntax error, unexpected T_VARIABLE, expecting T_STRING
in /home/sjoerd/www/mplate/mplate-0.2.1/Mplate/Taglib/Zend.php on line
47

And this:
Warning: preg_match() [function.preg-match]: Compilation failed:
unrecognized character after (? at offset 201 in /home/sjoerd/www/
mplate/mplate-0.2.1/Mplate/Compiler.php on line 437
For this regex:
~^(?P<t>.*?) (?:(?!\{ /? (?:if|else|foreach|foreachelse|ld|rd|lde|rde|
capture|strip|include|inline|raw|wrap|expandTaglib |assign|repeat|c:\w+|
p:\w+|zend:\w+)) \{ (?P<e>[^()]*? (?P<rr2\( (?>[^()]+ | (?&rr2) )*?
\) )? [^()]*? /?) \}|\{ (?P<f>/? (?:if|else|foreach|foreachelse|ld|rd|
lde|rde|capture|strip|include|inline|raw|wrap|expa ndTaglib|assign|
repeat|c:\w+|p:\w+|zend:\w+)[^()]*? (?P<rr1\( (?>[^()]+ | (?
&rr1) )*? \) )? [^()]*? /?) \}) (?P<p>.?) ~isx

Egbert Teeselink
Guest
 
Posts: n/a
#2: Aug 6 '08

re: Re: New template engine - retry


On Aug 6, 10:02*pm, Sjoerd <sjoer...@gmail.comwrote:
Quote:
On 6 aug, 10:53, Egbert Teeselink <skreb...@gmail.comwrote:
>
Quote:
"mplate, a PHP template engine that Doesn't Suck(tm)" (or at least,
that's what I hope)
>
I got this:
Parse error: syntax error, unexpected T_VARIABLE, expecting T_STRING
in /home/sjoerd/www/mplate/mplate-0.2.1/Mplate/Taglib/Zend.php on line
47
>
And this:
Warning: preg_match() [function.preg-match]: Compilation failed:
unrecognized character after (? at offset 201 in /home/sjoerd/www/
mplate/mplate-0.2.1/Mplate/Compiler.php on line 437
For this regex:
~^(?P<t>.*?) (?:(?!\{ /? (?:if|else|foreach|foreachelse|ld|rd|lde|rde|
capture|strip|include|inline|raw|wrap|expandTaglib |assign|repeat|c:\w+|
p:\w+|zend:\w+)) \{ (?P<e>[^()]*? *(?P<rr2\( (?>[^()]+ | (?&rr2) )*?
\) )? *[^()]*? /?) \}|\{ (?P<f>/? (?:if|else|foreach|foreachelse|ld|rd|
lde|rde|capture|strip|include|inline|raw|wrap|expa ndTaglib|assign|
repeat|c:\w+|p:\w+|zend:\w+)[^()]*? *(?P<rr1\( (?>[^()]+ | (?
&rr1) )*? \) )? *[^()]*? /?) \}) (?P<p>.?) ~isx
Thanks for trying it out! Guess my "doesn't suck" claim was a bit
premature..

The regex bug puzzled me for a while, but now I got it - only the
latest PHP has a PCRE that supports the perl way of doing named
backreferences, or so it seems. I replaced it by an older syntax (that
I didn't know existed), so that should be fixed.

The Zend.php bug puzzles me even more, however - that file hasn't been
touched for a while (and has been included mostly as a showcase and
isn't particularly useful currently). My only guess is that PHP5
changed the way it expands variables inside strings at some new
version, but I haven't found anything in changelogs.

Obviously, I should do more testing on lower PHP versions. (and I
really hope that that was the problem).
I've published a new version at http://e.teeselink.nl/mplate/releases/mplate-0.2.2.zip
- if that still causes the error in Zend.php, deleting the file should
fix the problem (but remove the currently pretty useless "zend:"
namespace).

Thanks for the feedback,

-egbert
Sjoerd
Guest
 
Posts: n/a
#3: Aug 8 '08

re: Re: New template engine - retry


On Aug 7, 12:14*am, Egbert Teeselink <skreb...@gmail.comwrote:
Quote:
I've published a new version athttp://e.teeselink.nl/mplate/releases/mplate-0.2.2.zip
The example worked well. I saw that you also changed the name in the
example to Mplate. Another improvement to the example would be to
remove the if statement which switches on the current time, and
replace it with something like
if (rand(0, 1))
So that you can try the different scenarios simply by refreshing the
page.

I will try with some templates other than the example in the coming
days.
Closed Thread