Re: [PHP] Adding Loop / If support to a simple template engine

2005-04-06 Thread Adrian
Just make your template engine compile templates to "native" php code. i.e. write a parser which replaces {if $foo}{$var}{/if} with templateVars['var'];?> To check if the template must be recompiled, just compare filemtimes. The assign function could be look like this then: = function assign($

Re: [PHP] Adding Loop / If support to a simple template engine

2005-04-06 Thread Richard Lynch
On Wed, April 6, 2005 8:07 pm, James Williams said: > Thanks everybody, but is this not already a really simple parser? I dunno what a CS Major would say, even though I was one, once upon a time, but I'd say "No." I don't call it a parser until you start tearing apart the text, and making decisio

Re: [PHP] Adding Loop / If support to a simple template engine

2005-04-06 Thread James Williams
Thanks everybody, but is this not already a really simple parser? class tpl { // // USER ACCESIBLE VARIABLES // // // PRIVATE CLASS VARIABLES // var $_template; // // USER DEFINED VARIABLES // var $tpl_directory; // REQUIRED - LOCATION OF THE TEMPLATES var $var_brace

Re: [PHP] Adding Loop / If support to a simple template engine

2005-04-06 Thread Drewcore
a parser is a program that i will take some preformatted text, extract the information from it, and then do work with that information. xml programs users parses to pull data from between the <> tags. in your case, you'd have to have some sort of declaration in your code that sets apart code block

Re: [PHP] Adding Loop / If support to a simple template engine

2005-04-06 Thread James Williams
Richard Lynch wrote: On Wed, April 6, 2005 7:04 pm, James Williams said: Hey fellas, I'm makin a forum right now and as a sub project, I'm making a template engine / class. Right now all it does is variable replacement, however I am curious as to how I can implement support for loops and if statem

Re: [PHP] Adding Loop / If support to a simple template engine

2005-04-06 Thread Richard Lynch
On Wed, April 6, 2005 7:04 pm, James Williams said: > Hey fellas, I'm makin a forum right now and as a sub project, I'm making > a template engine / class. Right now all it does is variable > replacement, however I am curious as to how I can implement support for > loops and if statements. I woul

[PHP] Adding Loop / If support to a simple template engine

2005-04-06 Thread James Williams
Hey fellas, I'm makin a forum right now and as a sub project, I'm making a template engine / class. Right now all it does is variable replacement, however I am curious as to how I can implement support for loops and if statements. I would appreciate any ideas that you may have, thank-you! Che