Add example

This commit is contained in:
bzick 2014-11-06 22:31:59 +03:00
parent f532658cc4
commit b0422ad43c
7 changed files with 56 additions and 52 deletions

View File

@ -1,19 +1,8 @@
<?php <?php
require_once __DIR__.'/../src/Fenom.php';
namespace Ts { \Fenom::registerAutoload();
class Math {
public static function multi($x, $y) {
return $x * $y;
}
}
}
namespace { $fenom = Fenom::factory(__DIR__.'/templates', __DIR__.'/compiled', Fenom::AUTO_RELOAD | Fenom::AUTO_ESCAPE);
require_once __DIR__.'/../src/Fenom.php';
\Fenom::registerAutoload(); $fenom->display('greeting.tpl');
$fenom = Fenom::factory(__DIR__.'/templates', __DIR__.'/compiled', Fenom::FORCE_COMPILE);
var_dump($fenom->compile("concat-bug.tpl", false)->getBody());
}

View File

@ -1,2 +0,0 @@
Some eval:
{$dop_content = ": some texta"}

View File

@ -1,13 +0,0 @@
{extends 'extends/75-parent.tpl'}
{block 'child'}
{macro child_test(v, i)}
child test - {$v}, i = {$i};<br/>
{var $i = $i -1}
{if $i > 0}
{macro.child_test v=$v i=$i}
{/if}
{/macro}
child call: <br/>
{macro.child_test v = 'ok' i = 5}
{/block}

View File

@ -1,12 +0,0 @@
{macro parent_test(v, i)}
parent test - {$v}, i = {$i};<br/>
{var $i = $i -1}
{if $i > 0}
{macro.parent_test v=$v i=$i}
{/if}
{/macro}
{block 'child'}{/block}
parent call:<br/>
{macro.parent_test v = 'ok' i = 5} <br/>

View File

@ -1,7 +1,40 @@
{var:escape $a} {include "header.tpl" title=""}
asdasd
{/var}
{*{Ts\Math::multi x=34 y=44}*} {import 'macros.tpl' as menu}
{*{$a + Ts\Math::multi(34, 44)}*}
{*{34|Ts\Math::multi:44}*} {menu.pills active='sandbox' items=$items}
<div class="jumbotron">
<h1>Jumbotron heading</h1>
<p class="lead">Cras justo odio, dapibus ac facilisis in, egestas eget quam. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p>
<p><a class="btn btn-lg btn-success" href="#" role="button">Sign up today</a></p>
</div>
<div class="row marketing">
{set $text}
<div class="col-lg-6">
<h4>Subheading</h4>
<p>Donec id elit non mi porta gravida at eget metus. Maecenas faucibus mollis interdum.</p>
<h4>Subheading</h4>
<p>Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Cras mattis consectetur purus sit amet fermentum.</p>
<h4>Subheading</h4>
<p>Maecenas sed diam eget risus varius blandit sit amet non magna.</p>
</div>
{/set}
{$text}
<div class="col-lg-6">
<h4>Subheading</h4>
<p>Donec id elit non mi porta gravida at eget metus. Maecenas faucibus mollis interdum.</p>
<h4>Subheading</h4>
<p>Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Cras mattis consectetur purus sit amet fermentum.</p>
<h4>Subheading</h4>
<p>Maecenas sed diam eget risus varius blandit sit amet non magna.</p>
</div>
</div>
{include "footer.tpl"}

View File

@ -1,5 +1,14 @@
{macro factorial(num)} {macro pills($title, $items, $active)}
{if $num} <div class="header">
{$num} {macro.factorial num=$num-1} {$num} <ul class="nav nav-pills pull-right" role="tablist">
{/if} {foreach $items as $code => $item}
{if $code == $active}
<li role="presentation" class="{$code}"><a href="">{$item.name}</a></li>
{else}
<li role="presentation" class="active {$code}"><a href="{$item.url}">{$item.name}</a></li>
{/if}
{/foreach}
</ul>
<h3 class="text-muted">{$title}</h3>
</div>
{/macro} {/macro}