Go to file
Ivan Shalganov 90e63b7103 Upd docs
2013-02-01 19:13:07 +04:00
benchmark Add benchmark 2013-01-25 19:13:33 +04:00
docs Upd docs 2013-02-01 19:13:07 +04:00
src Fixes 2013-01-28 16:34:34 +04:00
tests Add benchmark 2013-01-25 19:13:33 +04:00
.gitignore port 2013-01-25 18:36:16 +04:00
composer.json Add benchmark 2013-01-25 19:13:33 +04:00
phpunit.xml.dist port 2013-01-25 18:36:16 +04:00
README.md Upd docs 2013-02-01 19:13:07 +04:00

Aspect Template Engine

Templates looks like Smarty:

<html>
    <head>
        <title>Aspect</title>
    </head>
    <body>
    {if $user?} {* or {if !empty($user)} *}
        <div>User name: {$user.name}</div>
        <ul>
        {foreach $user.actions as $action}
            <li>{$action.name} ({$action.timestamp|gmdate:"Y-m-d H:i:s"})</li>
        {/foreach}
        </ul>
    {/if}
    </body>
</html>

Display template

$aspect = Aspect::factory('./templates', './compiled', Aspect::CHECK_MTIME);
$aspect->display("pages/about.tpl", $data);

Fetch template's result^

$aspect = Aspect::factory('./templates', './compiled', Aspect::CHECK_MTIME);
$content = $aspect->fetch("pages/about.tpl", $data);

Runtime compilation

$aspect = new Aspect();
$tempate = $aspect->compileCode('Hello {$user.name}! {if $user.email?} Your email: {$user.email} {/if}');
$tempate->display($data);
$content = $tempate->fetch($data);