Re: Adding Loop / If support to a simple template engine

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Just make your template engine compile templates to "native" php code.
i.e. write a parser which replaces {if $foo}{$var}{/if} with
<?php if($foo) {?><?php echo $this->templateVars['var'];?><?php } ?>

To check if the template must be recompiled, just compare filemtimes.
The assign function could be look like this then:
=====
function assign($varName, $value = '')
{
    if(is_array($varName))
        foreach($varName as $key => $val)
            $this->assign($key, $val);
    else
        $this->templateVars[$varName] = $value;
}
=====

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux