News 
22 January 2011

RainTPL 2.5 released

In about a month RainTpl evolved from version 2 to version 2.5, considering first version evolved slowly in about 4 years to version 2, this is a big jump!

So let's see the Rain TPL 2.5 changes:

  • {empty} tag removed, instead you can use {else} tag for the loop too, as following example:
    {loop="user_list"}
       {$key}  - {$value}<br>
    {else}
       No user found
    {/loop}


  • static cache, introduced in 2.4.9, is now definitely part of the class with the following syntax.

    Example:
    <?php

        //include RainTPL

        include 'inc/rain.tpl.class.php';

        //initialize
        $tpl = new RainTPL();

        // if there's a valid cache the method will return it
        if( $cache = $tpl->cache( 'test', $expire_time = 600 ) )
             echo $cache;
        else{
            ... query, operation, assign ....

            //draw template...

            $tpl->draw( 'test' );
        }

    ?>

     

  • {include} tag with cache option, we fixed a bug of this tag in beta version, and now it is definetely implemented the static cache option, to use as following:
    Example
    {include="footer" cache="3600"}
  • short tag, you can use now short tags {loop="..."} is equivalent to {loop name="..."}.

  • TPL_EXT re-introduced, so you can configure your template extension (html, tpl also php).

  • RAINTPL_CHECK_TEMPLATE_UPDATE, by default Rain checks templates changes, to know when re-compile them. You can disable this check by set RAINTPL_CHECK_TEMPLATE_UPDATE to false. If Rain doesn't have write permission on the cache directory, you can do a work-around, by disabling this constant and let Rain loads the compiled template without any check.

  • Minor changes, few little improments in the source was done, as now  {loop="$var"} is equivalent to {loop name="var"} to avoid common syntax error in writing templates. We optimized every single part of Rain source code to improve the speed, and as you can see now in the Benchmark page, is actually one of the faster template.

Rain Tpl

Easy PHP template engine which compiles templates.

Join the Google Group
rain google group