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

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}
asdasd
{/var}
{include "header.tpl" title=""}
{*{Ts\Math::multi x=34 y=44}*}
{*{$a + Ts\Math::multi(34, 44)}*}
{*{34|Ts\Math::multi:44}*}
{import 'macros.tpl' as menu}
{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)}
{if $num}
{$num} {macro.factorial num=$num-1} {$num}
{macro pills($title, $items, $active)}
<div class="header">
<ul class="nav nav-pills pull-right" role="tablist">
{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}