mirror of
https://github.com/fenom-template/fenom.git
synced 2023-08-10 21:13:07 +03:00
0659d27878
Add docs |
||
---|---|---|
benchmark | ||
docs | ||
src | ||
tests | ||
.gitignore | ||
.travis.yml | ||
composer.json | ||
phpunit.xml.dist | ||
README.md |
Aspect PHP Template Engine
Composer package: n/a
About | Documentation | Benchmark | Bugs | Articles
Smarty-like syntax:
<html>
<head>
<title>Aspect</title>
</head>
<body>
{if $templaters.aspect?}
{var $tpl = $templaters.aspect}
<div>Name: {$tpl.name}</div>
<div>Description: {$tpl.name|truncate:80}</div>
<ul>
{foreach $tpl.features as $feature}
<li>{$feature.name} (from {$feature.timestamp|gmdate:"Y-m-d H:i:s"})</li>
{/foreach}
</ul>
{/if}
</body>
</html>
Display template
<?php
$aspect = Aspect::factory('./templates', './compiled', Aspect::CHECK_MTIME);
$aspect->display("pages/about.tpl", $data);
Get content
<?php
$aspect = Aspect::factory('./templates', './compiled', Aspect::CHECK_MTIME);
$content = $aspect->fetch("pages/about.tpl", $data);
Runtime compilation
<?php
$aspect = new Aspect();
$tempate = $aspect->compileCode('Hello {$user.name}! {if $user.email?} Your email: {$user.email} {/if}');
$tempate->display($data);
// or
$content = $tempate->fetch($data);