Re: how are u parsing

From: Date: Thu, 05 Jul 2001 14:13:15 +0000
Subject: Re: how are u parsing
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-1117@lists.php.net to get a copy of this message
On Thu, 05 Jul 2001, Marc Logemann wrote: > Hi, > > first of all, i love your engine. > > My question: How do you parse the vars in the templates? (i mean from the > php view) > > Do you use string functions or ereg_* or preg_* functions, to replace vars > with assigned text? > > I am just writing some i18n functions in php and i get better results with > strstr in a loop, as with preg_replace() (not in a loop because you can > do tricky things like > > preg_replace("/<\\$([0-9])>/e", '$parmarray[\1]', $string); > > I think you should have some experiences in writing parsers :)) The engine uses preg_* regular expressions to extract the template commands from the file. Then it compiles the commands into PHP code, interleaves the results with the original text blocks, and writes out the compiled template code. After that it just keeps using the compiled version. -Andrei * Proximity bug: when the program crashes in front of important visitors. *

« previous php.smarty.general (#1117) next »