[geeklog-devel] caching template library

Joe Mucchiello joe at ThrowingDice.com
Mon Nov 5 14:46:09 EST 2007


So, I'm home and had 30 minutes to spend on the library. Here's my 
version of "if" taken from story.thtml. Basically {!if xyz} 
translates to if ($template->get_var('xyz')). The story code is nice 
enough to put the trackbacks_count into the template as a variable so 
if want different text when there are no trackbacks:

{!if trackbacks_count}
         {start_trackbacks_anchortag}{trackbacks_with_count}{end_trackbacks_anchortag}
{!else}
<br>{$LANG_TRB['no_comments']}
{!endif}

I used {!keyword} because I presume there are no existing template 
vars (in any GL code/plugins) prefixing their variables with an 
exclamation point.

Implementing this adds 8 lines of code to the my existing library and 
has no runtime expense beyond the if and call to get_var(). This is 
basically what FLEXY gives you for "if variable". Of course, since 
the library uses Regex you can create havoc by not balancing your ifs 
and endifs. {!elseif xyz} is also implemented in this edit.

----
Joe Mucchiello
Throwing Dice Games
http://www.throwingdice.com 




More information about the geeklog-devel mailing list