mirror of
https://github.com/fenom-template/fenom.git
synced 2023-08-10 21:13:07 +03:00
docs | ||
sandbox | ||
src | ||
tests | ||
.coveralls.yml | ||
.gitignore | ||
.travis.yml | ||
authors.md | ||
CHANGELOG.md | ||
composer.json | ||
license.md | ||
phpunit.xml.dist | ||
README.md |
Fenom - Template Engine for PHP
Composer package:
{"fenom/fenom": "2.*"}
. For old version:{"fenom/fenom": "1.*"}
. List of incompatibilities between 1.* and 2.* versions.
Usage :: Documentation :: Benchmark :: Articles
What is it
Fenom (from "fenomenal") — шаблонизатор на PHP с большими возможностями и синтаксисом Smarty.
Simple template
<html>
<head>
<title>Fenom</title>
</head>
<body>
{if $templaters.fenom?}
{var $tpl = $templaters.fenom}
<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
$fenom = Fenom::factory('./templates', './compiled', Fenom::AUTO_RELOAD);
$fenom->display("pages/about.tpl", $data);
Get content
<?php
$fenom = Fenom::factory('./templates', './compiled', Fenom::AUTO_RELOAD);
$content = $fenom->fetch("pages/about.tpl", $data);
Runtime compilation
<?php
$fenom = new Fenom();
$template = $fenom->compileCode('Hello {$user.name}! {if $user.email?} Your email: {$user.email} {/if}');
$template->display($data);
// or
$content = $template->fetch($data);