mirror of
https://github.com/fenom-template/fenom.git
synced 2023-08-10 21:13:07 +03:00
9d25ec31a7
Conflicts: README.md |
||
---|---|---|
benchmark | ||
docs | ||
src | ||
tests | ||
.gitignore | ||
composer.json | ||
phpunit.xml.dist | ||
README.md |
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);