Page 1 of 1

Really simple Smartys?

Posted: Tue Apr 19, 2005 8:57 am
by Todd_Z
Has anyone developed a really simple version of smarty? Meaning just iterative sections and variables - I don't want to have such a complicated template system - creates too much overhead in size and loading time.

Posted: Tue Apr 19, 2005 9:00 am
by feyd
depending on your needs, a simple regex can perform the task quite fast.. unless you need logic controls.. then it gets a bit hairy, quickly.

Posted: Tue Apr 19, 2005 9:05 am
by Todd_Z
I'm pretty sure that I can strip the code down to simple foreach statements... How would i do it with regexs?

Posted: Tue Apr 19, 2005 9:09 am
by feyd
store that template block in a seed string, loop over the block list sending the current data through the regex along with the seed string. Store the result into your output buffer or simply echo if no further processing is needed.

I use preg_replace() and the 'e' (evaluate) modifier to do this in my streamlined template engines.

Posted: Tue Apr 19, 2005 9:17 am
by Todd_Z
uh.... I'm not a n00b or anything - but I still have no idea what you just said :cry: Especially about a seed string <- whats that?

Posted: Tue Apr 19, 2005 9:28 am
by feyd
Store the template block into a string. This string is not to be changed throughout the processing of the block. You simply pass that string as the text to run the regex on.

¿comprenda?

Posted: Tue Apr 19, 2005 9:38 am
by Todd_Z
http://www.acdrifter.com/Templates/Reviews-Template.php

I guess that would be the block that doesn't change.

Every variable with the name "Page____" would be a static variable.
Reviews would be an array of objects
Review would be an object with variables to access - I figure that accessing variables instead of calling methods would be easier for me at this point.

So now that I have that, what kind of regex would iterate over that section?