Add checking nested level for {use} and {extends}

Add more docs
This commit is contained in:
bzick
2013-07-02 11:07:33 +04:00
parent 27d7110690
commit c76f5c8be0
11 changed files with 148 additions and 77 deletions

View File

@ -1,11 +0,0 @@
About Fenom [RU]
================
Fenom - самый быстрый, гибкий и тонкий шаблонизатор для PHP, унаследовавший синтаксис от Smarty3 и улучшив его.
Пожалуй это единственный шаблонизатор, который не использет ни регулярные выражения, как Twig, ни лексер от BISON, как Smarty3.
Вы не найдёте ни одного регулярного выражения в ядре Fenom, но тем не менее ядро простое, компактное и очень быстрое.
* Скорость. Разбор шаблонов постоен на основе нативного [токенайзера](http://docs.php.net/tokenizer). Шаблон преобразуется в исполняемый PHP код,
который может быть закеширован на файловой системе.
* Безопасность. Разборщик шаблон кроптоливо проверяет каждый токен, тем самым не пропуская возможные уязвимоти и фатальные ошибки при исполнении шпблона.
* Гибкость. Любой компонент можно переопределить, по желанию.

View File

@ -5,11 +5,11 @@ For installation use [composer](http://getcompoer.org). Add in your `composer.js
```json
{
"require": {
"bzick/fenom": "dev-master"
"fenom/fenom": "dev-master"
}
}
```
or use shell
`composer require bzick/fenom`
`composer require fenom/fenom`
If you do not use composer - use `psr-0` format for loading Fenom's classes.

View File

@ -1,22 +1,67 @@
Operators
=========
Math
### Math
`+ - / *`
Operators: `+ - / *`
Bitwize
```smarty
{$a + $b * $c/$d - $e*5 + 1e3}
```
`| & << >> |= &= <<= >>=`
### Boolean
Unary
Operators: `|| && and or < > <= >= == === !== !=`
`^ ~ - !`
```smarty
{if $a && $b >= 5 && $c != 3} {/if}
```
Boolean
### Bitwize
`|| && and or < > <= >= == === !== !=`
Operators: `| & << >> |= &= <<= >>=`
Ternar
```smarty
{if $a & 1} {var $b |= $flags} {/if}
```
`? :`
### Unary
Operators: `^ ~ - !`
```smarty
{var $b |= $flags & ^$c}
```
### Ternar
Operators: `? :`
```smarty
{var $a = true}
{$a ? 5 : 10} {* outputs 5 *}
{var $a = false}
{$a ? 5 : 10} {* outputs 10 *}
```
### Variable operator
Checking variable value
```smarty
{if $a?} {* instead of {if !empty($a)} *}
```
Checking variable existence
```smarty
{if $a!} {* instead of {if isset($a)} *}
```
Get default if variable is empty
```smarty
{$a?:"some text"} {* instead of {if empty($a) ? "some text" : $a} *}
```
Get default if variable doesn't exist
```smarty
{$a!:"some text"} {* instead of {if isset($a) ? $a : "some text"} *}
```

View File

@ -25,6 +25,7 @@ $fenom->setOptions($options);
* **auto_reload**, `Fenom::AUTO_RELOAD`, пересобирать шаблон если его оригинал был изменён (замедляет работу шаблонизатора).
* **force_compile**, `Fenom::FORCE_COMPILE`, пересобирать шаблон при каждом вызове (сильно замедляет работу шаблонизатора).
* **force_include**, `Fenom::FORCE_INCLUDE`, оптимизировать вставку шаблона в шаблон. Это увеличит производительность и размер собранного шаблона.
Опция активируется если имя шаблона задано явно и скалярно.
```php
$fenom->setOptions(array(

View File

@ -1,20 +1,38 @@
Basic usage
===========
### Creating template engine
### Initialize Fenom
Use factory method
```php
$fenom = Fenom::factory('/path/to/templates', '/path/to/template/cache', $options);
$fenom = Fenom::factory('/path/to/templates', '/path/to/compiled/template', $options);
```
//or
$fenom = new Fenom(new FSProvider('/path/to/templates'));
Use `new` operator
```php
$fenom = new Fenom(new Provider('/path/to/templates'));
$fenom->setCompileDir('/path/to/template/cache');
$fenom->setOptions($options);
```
### Output template result
### Render template
Output template
```php
$fenom->display("template/name.tpl", $vars);
```
Get template into the variable
```php
$result = $fenom->fetch("template/name.tpl", $vars);
```
Create pipe-line into callback
```php
$fenom->export(
"template/sitemap.tpl",
$vars,
$callback = [new SplFileObject("/tmp/sitemap.xml", "w"), "fwrite"], // pipe to file /tmp/sitemap.xml
$chunk_size = 1e6 // chunk size for callback
);
```