2013-07-02 11:07:33 +04:00
|
|
|
Fenom - Template Engine for PHP
|
|
|
|
===============================
|
2013-01-28 12:04:07 +04:00
|
|
|
|
2013-07-02 11:07:33 +04:00
|
|
|
> Composer package: `{"fenom/fenom": "dev-master"}`. See on [Packagist.org](https://packagist.org/packages/bzick/fenom)
|
2013-02-07 20:04:00 +04:00
|
|
|
|
2013-06-28 11:53:53 +04:00
|
|
|
[![Build Status](https://travis-ci.org/bzick/fenom.png?branch=master)](https://travis-ci.org/bzick/fenom)
|
2013-07-02 11:07:33 +04:00
|
|
|
## [Usage](./docs/usage.md) :: [Documentation](./docs/main.md) :: [Benchmark](./docs/benchmark.md) :: [Articles](./docs/articles.md)
|
2013-02-07 17:37:16 +04:00
|
|
|
|
2013-07-02 11:07:33 +04:00
|
|
|
* Simple [syntax](./docs/syntax.md)
|
2013-02-26 23:56:06 +04:00
|
|
|
* [Fast](./docs/benchmark.md)
|
|
|
|
* [Secure](./docs/settings.md)
|
2013-03-15 01:24:52 +04:00
|
|
|
* [Simple](./ideology.md)
|
2013-02-26 23:56:06 +04:00
|
|
|
* [Flexible](./docs/main.md#extends)
|
2013-06-08 00:08:00 +04:00
|
|
|
* [Lightweight](./docs/benchmark.md#stats)
|
2013-02-27 00:17:31 +04:00
|
|
|
* [Powerful](./docs/main.md)
|
2013-02-27 20:55:47 +04:00
|
|
|
* Easy to use:
|
2013-02-24 14:09:28 +04:00
|
|
|
|
2013-02-28 22:29:51 +04:00
|
|
|
Simple template
|
2013-01-28 12:04:07 +04:00
|
|
|
|
2013-02-01 19:13:07 +04:00
|
|
|
```smarty
|
|
|
|
<html>
|
|
|
|
<head>
|
2013-06-28 11:53:53 +04:00
|
|
|
<title>Fenom</title>
|
2013-02-01 19:13:07 +04:00
|
|
|
</head>
|
|
|
|
<body>
|
2013-06-28 11:53:53 +04:00
|
|
|
{if $templaters.fenom?}
|
|
|
|
{var $tpl = $templaters.fenom}
|
2013-02-07 17:37:16 +04:00
|
|
|
<div>Name: {$tpl.name}</div>
|
|
|
|
<div>Description: {$tpl.name|truncate:80}</div>
|
2013-02-01 19:13:07 +04:00
|
|
|
<ul>
|
2013-02-07 17:37:16 +04:00
|
|
|
{foreach $tpl.features as $feature}
|
|
|
|
<li>{$feature.name} (from {$feature.timestamp|gmdate:"Y-m-d H:i:s"})</li>
|
2013-02-01 19:13:07 +04:00
|
|
|
{/foreach}
|
|
|
|
</ul>
|
|
|
|
{/if}
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
```
|
2013-01-28 12:04:07 +04:00
|
|
|
|
2013-02-01 19:13:07 +04:00
|
|
|
Display template
|
2013-01-28 12:04:07 +04:00
|
|
|
|
|
|
|
```php
|
2013-02-01 19:14:15 +04:00
|
|
|
<?php
|
2013-06-28 11:53:53 +04:00
|
|
|
$fenom = Fenom::factory('./templates', './compiled', Fenom::AUTO_RELOAD);
|
|
|
|
$fenom->display("pages/about.tpl", $data);
|
2013-01-28 12:04:07 +04:00
|
|
|
```
|
|
|
|
|
2013-02-07 17:37:16 +04:00
|
|
|
Get content
|
2013-01-28 12:04:07 +04:00
|
|
|
|
|
|
|
```php
|
2013-02-01 19:14:15 +04:00
|
|
|
<?php
|
2013-06-28 11:53:53 +04:00
|
|
|
$fenom = Fenom::factory('./templates', './compiled', Fenom::AUTO_RELOAD);
|
|
|
|
$content = $fenom->fetch("pages/about.tpl", $data);
|
2013-01-28 12:04:07 +04:00
|
|
|
```
|
|
|
|
|
2013-02-01 19:13:07 +04:00
|
|
|
Runtime compilation
|
2013-01-28 12:04:07 +04:00
|
|
|
|
|
|
|
```php
|
2013-02-01 19:14:15 +04:00
|
|
|
<?php
|
2013-06-28 11:53:53 +04:00
|
|
|
$fenom = new Fenom();
|
|
|
|
$template = $fenom->compileCode('Hello {$user.name}! {if $user.email?} Your email: {$user.email} {/if}');
|
|
|
|
$template->display($data);
|
2013-02-07 17:37:16 +04:00
|
|
|
// or
|
2013-06-28 11:53:53 +04:00
|
|
|
$content = $template->fetch($data);
|
2013-01-28 12:04:07 +04:00
|
|
|
```
|