2013-02-07 17:37:16 +04:00
|
|
|
Aspect PHP Template Engine
|
|
|
|
==========================
|
2013-01-28 12:04:07 +04:00
|
|
|
|
2013-02-07 20:04:00 +04:00
|
|
|
> Composer package: n/a
|
|
|
|
|
2013-02-09 11:32:11 +04:00
|
|
|
## [About](./docs/about.md) :: [Documentation](./docs/main.md) :: [Benchmark](./docs/benchmark.md) :: [Bugs](https://github.com/bzick/aspect/issues) :: [Articles](./docs/articles.md)
|
2013-02-07 17:37:16 +04:00
|
|
|
|
2013-02-07 19:22:13 +04:00
|
|
|
[![Build Status](https://travis-ci.org/bzick/aspect.png?branch=master)](https://travis-ci.org/bzick/aspect)
|
|
|
|
|
2013-02-09 11:32:11 +04:00
|
|
|
Primitive template
|
2013-01-28 12:04:07 +04:00
|
|
|
|
2013-02-01 19:13:07 +04:00
|
|
|
```smarty
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Aspect</title>
|
|
|
|
</head>
|
|
|
|
<body>
|
2013-02-07 17:37:16 +04:00
|
|
|
{if $templaters.aspect?}
|
|
|
|
{var $tpl = $templaters.aspect}
|
|
|
|
<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-01-28 15:51:17 +04:00
|
|
|
$aspect = Aspect::factory('./templates', './compiled', Aspect::CHECK_MTIME);
|
|
|
|
$aspect->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-01-28 15:51:17 +04:00
|
|
|
$aspect = Aspect::factory('./templates', './compiled', Aspect::CHECK_MTIME);
|
|
|
|
$content = $aspect->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-01-28 15:51:17 +04:00
|
|
|
$aspect = new Aspect();
|
|
|
|
$tempate = $aspect->compileCode('Hello {$user.name}! {if $user.email?} Your email: {$user.email} {/if}');
|
|
|
|
$tempate->display($data);
|
2013-02-07 17:37:16 +04:00
|
|
|
// or
|
2013-01-28 15:51:17 +04:00
|
|
|
$content = $tempate->fetch($data);
|
2013-01-28 12:04:07 +04:00
|
|
|
```
|