[geeklog-devel] caching template library

Joe Mucchiello jmucchiello at yahoo.com
Mon Oct 29 16:14:59 EDT 2007


This all had to come wait till I was on vacation, didn't it?

Thanks Vinny.

My opinion is that this code is now or never. As Mark has said, there
are several poor practices in plugins (and core code) where a template
is parsed then setvar is called and the output only looks right because
of the final call to finish. With the version change to 1.5 and with
the fact that ADMIN_list API was broken between versions, this is the
perfect time to say 1.4 plugins probably do not work with 1.5. Changing
the template library in some future 1.5.1 if these plugins with poor
practices break between 1.5 and 1.5.1. Much better to give the plugin
writers one large hump to get over than a series of smaller ones.

Additionally, I think this library would be perfect for your "little"
templates. Since the caching library works via "include", creating a
template called "rawlink.thtml":
    <a href="{url}" {extras}>{link}</a>
is not "expensive". The functions already exist (COM_createLink) the
implementations just need work:
function COM_createLink($content, $url, $attr = array())
{
    global $_CONF;
    static $T = false;
    if (!$T) {
        $T = new Template($_CONF['path_layout']);
        $T->set_file('rawlink.thtml');
    }
    $T->unset_var(Array('url','extras','link'));
    ... // should be obvious what follows
}
Or instead of one file per snippet, put a bunch of snippets into a
single file and use the setblock API to fish out the bits you need:
<!--- BEGIN ulist --->
<ul class="{ul_class}">
<!--- BEGIN listitem --->
<li class="{li_class}">
{li_content}</li>
<!--- END listitem --->
</ul>
<!--- END ulist --->
<!--- BEGIN link --->
<a href="{link_url}" {link_extras}>{link_content}</a>
<!--- END link --->
// etc with select/option pairs, ordered lists, even divs

Then a global template class instance could be used to process these
snippets as needed.

But that stuff gets pushed further into the future the longer the delay
of putting the template class into the core is delayed.

  Joe

At 11:49 AM 10/24/2007, Vincent Furia wrote:
> Joe,
>
> I think this would be great to get into the release.  The only
problem
> may be how bloated this release already is with all the GSOC and
other
> code changes.  I'll try to see if I can beat Michael to testing your
> code out and comparing performance.
>
> -Vinny


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



More information about the geeklog-devel mailing list