Go to file
bzick 281757b902 Add documentation for length modifier
Fix documentation for truncate modifier
2013-03-18 10:45:07 +04:00
benchmark Small refactoring 2013-03-17 14:37:23 +04:00
docs Add documentation for length modifier 2013-03-18 10:45:07 +04:00
src Add custom additionally options for template 2013-03-18 00:35:20 +04:00
tests Add custom additionally options for template 2013-03-18 00:35:20 +04:00
.gitignore Hold folders 2013-02-20 18:01:21 +04:00
.travis.yml Remove PHP 5.2 from travis.yml 2013-03-15 01:28:39 +04:00
composer.json Fix composer dependency 2013-03-14 22:40:31 +04:00
phpunit.xml.dist port 2013-01-25 18:36:16 +04:00
README.md Update readme 2013-03-15 01:24:52 +04:00

Aspect - awesome template engine for PHP

Composer package: {"bzick/aspect": "dev-master"}. See on Packagist.org

Build Status

About :: Documentation :: Benchmark :: Articles

Simple template

<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);