By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,614 Members | 1,662 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,614 IT Pros & Developers. It's quick & easy.

how to loop in templates?

P: n/a
having developed this simple template engine for my own projects,the
engine simply replaces the {replacable} tags with the appropriate
value.
the template file is read into a string variable $string ,then i use
preg_replace_callback to process the tags.
now,i have a problem with the loops.i've though about this:

{LOOP_NAME}
things to be {repeated}
{/LOOP}

then i though about using preg_replace_callback twice,once to extract
the loop body,repeat it then insert it back into $string.
then use the final preg_replace_callback to replace all {replacable}
variables.
is this a bad idea for server loads?

Apr 24 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
me******************@gmail.com wrote:
having developed this simple template engine for my own projects,the
engine simply replaces the {replacable} tags with the appropriate
value.
the template file is read into a string variable $string ,then i use
preg_replace_callback to process the tags.
now,i have a problem with the loops.i've though about this:

{LOOP_NAME}
things to be {repeated}
{/LOOP}

then i though about using preg_replace_callback twice,once to extract
the loop body,repeat it then insert it back into $string.
then use the final preg_replace_callback to replace all {replacable}
variables.
is this a bad idea for server loads?
I did something similar, and it took me a while to get it to work right, but I didn't have it working for long enough to get an idea of server loads. I now use Smarty template engine because it has more advanced features than I had time to make myself. It didn't seem THAT slow, but I remember wishing it were faster.

-Mike PII
Apr 25 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.