diff --git a/README.md b/README.md
index 59915eb..fb1a3ad 100644
--- a/README.md
+++ b/README.md
@@ -1,9 +1,9 @@
-Cytro - awesome template engine for PHP
+Fenom - awesome template engine for PHP
==========================
-> Composer package: `{"bzick/cytro": "dev-master"}`. See on [Packagist.org](https://packagist.org/packages/bzick/cytro)
+> Composer package: `{"bzick/fenom": "dev-master"}`. See on [Packagist.org](https://packagist.org/packages/bzick/fenom)
-[![Build Status](https://travis-ci.org/bzick/cytro.png?branch=master)](https://travis-ci.org/bzick/cytro)
+[![Build Status](https://travis-ci.org/bzick/fenom.png?branch=master)](https://travis-ci.org/bzick/fenom)
## [About](./docs/about.md) :: [Documentation](./docs/main.md) :: [Benchmark](./docs/benchmark.md) :: [Articles](./docs/articles.md)
* Simplest known [syntax](./docs/syntax.md)
@@ -20,11 +20,11 @@ Simple template
```smarty
- Cytro
+ Fenom
- {if $templaters.cytro?}
- {var $tpl = $templaters.cytro}
+ {if $templaters.fenom?}
+ {var $tpl = $templaters.fenom}
Name: {$tpl.name}
Description: {$tpl.name|truncate:80}
@@ -41,25 +41,25 @@ Display template
```php
display("pages/about.tpl", $data);
+$fenom = Fenom::factory('./templates', './compiled', Fenom::AUTO_RELOAD);
+$fenom->display("pages/about.tpl", $data);
```
Get content
```php
fetch("pages/about.tpl", $data);
+$fenom = Fenom::factory('./templates', './compiled', Fenom::AUTO_RELOAD);
+$content = $fenom->fetch("pages/about.tpl", $data);
```
Runtime compilation
```php
compileCode('Hello {$user.name}! {if $user.email?} Your email: {$user.email} {/if}');
-$tempate->display($data);
+$fenom = new Fenom();
+$template = $fenom->compileCode('Hello {$user.name}! {if $user.email?} Your email: {$user.email} {/if}');
+$template->display($data);
// or
-$content = $tempate->fetch($data);
+$content = $template->fetch($data);
```
diff --git a/benchmark/run.php b/benchmark/run.php
index aa6125f..e18c00f 100644
--- a/benchmark/run.php
+++ b/benchmark/run.php
@@ -2,7 +2,7 @@
require_once __DIR__.'/scripts/bootstrap.php';
exec("rm -rf ".__DIR__."/compile/*");
-echo "Smarty3 vs Twig vs Cytro\n\n";
+echo "Smarty3 vs Twig vs Fenom\n\n";
echo "Generate templates... ";
passthru("php ".__DIR__."/templates/inheritance/smarty.gen.php");
@@ -13,34 +13,34 @@ echo "Testing a lot output...\n";
Benchmark::runs("smarty3", 'echo/smarty.tpl', __DIR__.'/templates/echo/data.json');
Benchmark::runs("twig", 'echo/twig.tpl', __DIR__.'/templates/echo/data.json');
-Benchmark::runs("cytro", 'echo/smarty.tpl', __DIR__.'/templates/echo/data.json');
-//if(extension_loaded("phalcon")) {
-// Benchmark::runs("volt", 'echo/twig.tpl', __DIR__.'/templates/echo/data.json');
-//}
+Benchmark::runs("fenom", 'echo/smarty.tpl', __DIR__.'/templates/echo/data.json');
+if(extension_loaded("phalcon")) {
+ Benchmark::runs("volt", 'echo/twig.tpl', __DIR__.'/templates/echo/data.json');
+}
echo "\nTesting 'foreach' of big array...\n";
Benchmark::runs("smarty3", 'foreach/smarty.tpl', __DIR__.'/templates/foreach/data.json');
Benchmark::runs("twig", 'foreach/twig.tpl', __DIR__.'/templates/foreach/data.json');
-Benchmark::runs("cytro", 'foreach/smarty.tpl', __DIR__.'/templates/foreach/data.json');
-//if(extension_loaded("phalcon")) {
-// Benchmark::runs("volt", 'foreach/twig.tpl', __DIR__.'/templates/foreach/data.json');
-//}
+Benchmark::runs("fenom", 'foreach/smarty.tpl', __DIR__.'/templates/foreach/data.json');
+if(extension_loaded("phalcon")) {
+ Benchmark::runs("volt", 'foreach/twig.tpl', __DIR__.'/templates/foreach/data.json');
+}
echo "\nTesting deep 'inheritance'...\n";
Benchmark::runs("smarty3", 'inheritance/smarty/b100.tpl', __DIR__.'/templates/foreach/data.json');
Benchmark::runs("twig", 'inheritance/twig/b100.tpl', __DIR__.'/templates/foreach/data.json');
-Benchmark::runs("cytro", 'inheritance/smarty/b100.tpl', __DIR__.'/templates/foreach/data.json');
-//if(extension_loaded("phalcon")) {
-// Benchmark::runs("volt", 'inheritance/twig/b100.tpl', __DIR__.'/templates/foreach/data.json');
-//}
+Benchmark::runs("fenom", 'inheritance/smarty/b100.tpl', __DIR__.'/templates/foreach/data.json');
+if(extension_loaded("phalcon")) {
+ Benchmark::runs("volt", 'inheritance/twig/b100.tpl', __DIR__.'/templates/foreach/data.json');
+}
echo "\nDone. Cleanup.\n";
//passthru("rm -rf ".__DIR__."/compile/*");
passthru("rm -f ".__DIR__."/templates/inheritance/smarty/*");
passthru("rm -f ".__DIR__."/templates/inheritance/twig/*");
-echo "\nSmarty3 vs Cytro (more details)\n\n";
+echo "\nSmarty3 vs Fenom (more details)\n\n";
echo "Coming soon\n";
\ No newline at end of file
diff --git a/benchmark/scripts/bootstrap.php b/benchmark/scripts/bootstrap.php
index fe8da29..cc914b7 100644
--- a/benchmark/scripts/bootstrap.php
+++ b/benchmark/scripts/bootstrap.php
@@ -43,15 +43,15 @@ class Benchmark {
printf(self::$t, __FUNCTION__, $message, round(microtime(true)-$start, 4), round(memory_get_peak_usage()/1024/1024, 2));
}
- public static function cytro($tpl, $data, $double, $message) {
+ public static function fenom($tpl, $data, $double, $message) {
- $cytro = Cytro::factory(__DIR__.'/../templates', __DIR__."/../compile");
+ $fenom = Fenom::factory(__DIR__.'/../templates', __DIR__."/../compile");
if($double) {
- $cytro->fetch($tpl, $data);
+ $fenom->fetch($tpl, $data);
}
$_SERVER["t"] = $start = microtime(true);
- $cytro->fetch($tpl, $data);
+ $fenom->fetch($tpl, $data);
printf(self::$t, __FUNCTION__, $message, round(microtime(true)-$start, 4), round(memory_get_peak_usage()/1024/1024, 2));
}
diff --git a/benchmark/templates/echo.php b/benchmark/templates/echo.php
deleted file mode 100644
index 8240abd..0000000
--- a/benchmark/templates/echo.php
+++ /dev/null
@@ -1,65 +0,0 @@
-compile_check = false;
-
-$smarty->setTemplateDir(__DIR__);
-$smarty->setCompileDir(__DIR__."/../compile/");
-
-$start = microtime(true);
-$smarty->assign($data);
-$smarty->fetch('echo/smarty.tpl');
-var_dump("Smarty3: ".(microtime(true)-$start));
-
-$start = microtime(true);
-$smarty->assign($data);
-$smarty->fetch('echo/smarty.tpl');
-var_dump("Smarty3 cached: ".(microtime(true)-$start));
-
-Twig_Autoloader::register();
-$loader = new Twig_Loader_Filesystem(__DIR__);
-$twig = new Twig_Environment($loader, array(
- 'cache' => __DIR__."/../compile/",
- 'autoescape' => false,
- 'auto_reload' => false,
-));
-
-$start = microtime(true);
-$template = $twig->loadTemplate('echo/twig.tpl');
-$template->render($data);
-var_dump("Twig: ".(microtime(true)-$start));
-
-$start = microtime(true);
-$template = $twig->loadTemplate('echo/twig.tpl');
-$template->render($data);
-var_dump("Twig cached: ".(microtime(true)-$start));
-
-$cytro = Cytro::factory(__DIR__, __DIR__."/../compile/", Cytro::AUTO_RELOAD);
-
-$start = microtime(true);
-$template = $cytro->fetch('echo/smarty.tpl', $data);
-var_dump("Cytro: ".(microtime(true)-$start));
-
-$start = microtime(true);
-$template = $cytro->fetch('echo/smarty.tpl', $data);
-var_dump("Cytro cached: ".(microtime(true)-$start));
-
diff --git a/benchmark/templates/foreach.php b/benchmark/templates/foreach.php
deleted file mode 100644
index 1df7c6b..0000000
--- a/benchmark/templates/foreach.php
+++ /dev/null
@@ -1,50 +0,0 @@
-compile_check = true;
-
-$smarty->setTemplateDir(__DIR__);
-$smarty->setCompileDir(__DIR__."/../compile/");
-
-$start = microtime(true);
-$smarty->assign($data);
-$smarty->fetch('foreach/smarty.tpl');
-var_dump("Smarty3: ".(microtime(true)-$start));
-
-$start = microtime(true);
-$smarty->assign($data);
-$smarty->fetch('foreach/smarty.tpl');
-var_dump("Smarty3 cached: ".(microtime(true)-$start));
-
-Twig_Autoloader::register();
-$loader = new Twig_Loader_Filesystem(__DIR__);
-$twig = new Twig_Environment($loader, array(
- 'cache' => __DIR__."/../compile/",
- 'autoescape' => false,
- 'auto_reload' => false,
-));
-
-$start = microtime(true);
-$template = $twig->loadTemplate('foreach/twig.tpl');
-$template->render($data);
-var_dump("Twig: ".(microtime(true)-$start));
-
-$start = microtime(true);
-$template = $twig->loadTemplate('foreach/twig.tpl');
-$template->render($data);
-var_dump("Twig cached: ".(microtime(true)-$start));
-
-$cytro = Cytro::factory(__DIR__, __DIR__."/../compile/", Cytro::AUTO_RELOAD);
-
-$start = microtime(true);
-$template = $cytro->fetch('foreach/smarty.tpl', $data);
-var_dump("Cytro: ".(microtime(true)-$start));
-
-$start = microtime(true);
-$template = $cytro->fetch('foreach/smarty.tpl', $data);
-var_dump("Cytro cached: ".(microtime(true)-$start));
-
diff --git a/benchmark/templates/inheritance.php b/benchmark/templates/inheritance.php
deleted file mode 100644
index 7b170f9..0000000
--- a/benchmark/templates/inheritance.php
+++ /dev/null
@@ -1,61 +0,0 @@
- 'inheritance',
- "var1" => 'val1'
-);
-
-function trace() {
- $e = new Exception();
- echo $e->getTraceAsString();
- ob_flush();
- exit(0);
-}
-
-exec("rm -rf ".__DIR__."/../compile/*");
-
-require(__DIR__.'/../../vendor/autoload.php');
-
-$smarty = new Smarty();
-$smarty->compile_check = true;
-
-$smarty->setTemplateDir(__DIR__);
-$smarty->setCompileDir(__DIR__."/../compile/");
-
-$start = microtime(true);
-$smarty->assign($data);
-$smarty->fetch('inheritance/smarty/b100.tpl');
-var_dump("Smarty3: ".(microtime(true)-$start));
-
-$start = microtime(true);
-$smarty->assign($data);
-$smarty->fetch('inheritance/smarty/b100.tpl');
-var_dump("Smarty3 cached: ".(microtime(true)-$start));
-
-Twig_Autoloader::register();
-$loader = new Twig_Loader_Filesystem(__DIR__);
-$twig = new Twig_Environment($loader, array(
- 'cache' => __DIR__."/../compile/",
- 'autoescape' => false,
- 'auto_reload' => false,
-));
-
-$start = microtime(true);
-$template = $twig->loadTemplate('inheritance/twig/b100.tpl');
-$template->render($data);
-var_dump("Twig: ".(microtime(true)-$start));
-
-$start = microtime(true);
-$template = $twig->loadTemplate('inheritance/twig/b100.tpl');
-$template->render($data);
-var_dump("Twig cached: ".(microtime(true)-$start));
-
-$cytro = Cytro::factory(__DIR__, __DIR__."/../compile/", Cytro::AUTO_RELOAD);
-
-$start = microtime(true);
-$template = $cytro->fetch('inheritance/smarty/b100.tpl', $data);
-var_dump("Cytro: ".(microtime(true)-$start));
-
-$start = microtime(true);
-$template = $cytro->fetch('inheritance/smarty/b100.tpl', $data);
-var_dump("Cytro cached: ".(microtime(true)-$start));
-
diff --git a/composer.json b/composer.json
index d3f0290..47685b2 100644
--- a/composer.json
+++ b/composer.json
@@ -1,9 +1,9 @@
{
- "name": "bzick/cytro",
+ "name": "bzick/fenom",
"type": "library",
- "description": "Cytro - fast template engine for PHP",
- "homepage": "http://bzick.github.io/cytro/",
- "keywords": ["cytro", "template", "templating"],
+ "description": "Fenom - fast template engine for PHP",
+ "homepage": "http://bzick.github.io/fenom/",
+ "keywords": ["fenom", "template", "templating"],
"license": "BSD-3",
"authors": [
{
@@ -22,7 +22,7 @@
"twig/twig": "1.*"
},
"autoload": {
- "psr-0": { "Cytro\\": "src/" },
- "classmap": [ "src/Cytro.php" ]
+ "psr-0": { "Fenom\\": "src/" },
+ "classmap": [ "src/Fenom.php" ]
}
}
diff --git a/docs/about.md b/docs/about.md
index ce4fc8b..fa4c1b8 100644
--- a/docs/about.md
+++ b/docs/about.md
@@ -1,9 +1,9 @@
-About Cytro [RU]
+About Fenom [RU]
================
-Cytro - самый быстрый, гибкий и тонкий шаблонизатор для PHP, унаследовавший синтаксис от Smarty3 и улучшив его.
+Fenom - самый быстрый, гибкий и тонкий шаблонизатор для PHP, унаследовавший синтаксис от Smarty3 и улучшив его.
Пожалуй это единственный шаблонизатор, который не использет ни регулярные выражения, как Twig, ни лексер от BISON, как Smarty3.
-Вы не найдёте ни одного регулярного выражения в ядре Cytro, но тем не менее ядро простое, компактное и очень быстрое.
+Вы не найдёте ни одного регулярного выражения в ядре Fenom, но тем не менее ядро простое, компактное и очень быстрое.
* Скорость. Разбор шаблонов постоен на основе нативного [токенайзера](http://docs.php.net/tokenizer). Шаблон преобразуется в исполняемый PHP код,
который может быть закеширован на файловой системе.
diff --git a/docs/benchmark.md b/docs/benchmark.md
index 0a5b213..c6fc4f7 100644
--- a/docs/benchmark.md
+++ b/docs/benchmark.md
@@ -3,7 +3,7 @@ Benchmark
To start benchmark run script `benchmark/run.php`.
-### Smarty3 vs Twig vs Cytro
+### Smarty3 vs Twig vs Fenom
PHP 5.4.11
@@ -17,9 +17,9 @@ PHP 5.4.11
twig: compiled and !loaded 0.0337 sec, 16.1 MiB
twig: compiled and loaded 0.0027 sec, 16.1 MiB
- cytro: !compiled and !loaded 1.0142 sec, 8.8 MiB
- cytro: compiled and !loaded 0.0167 sec, 6.1 MiB
- cytro: compiled and loaded 0.0024 sec, 6.1 MiB
+ fenom: !compiled and !loaded 1.0142 sec, 8.8 MiB
+ fenom: compiled and !loaded 0.0167 sec, 6.1 MiB
+ fenom: compiled and loaded 0.0024 sec, 6.1 MiB
Iterating of array ({foreach})
@@ -31,9 +31,9 @@ PHP 5.4.11
twig: compiled and !loaded 0.0605 sec, 2.9 MiB
twig: compiled and loaded 0.0550 sec, 2.9 MiB
- cytro: !compiled and !loaded 0.0093 sec, 3.0 MiB
- cytro: compiled and !loaded 0.0033 sec, 2.4 MiB
- cytro: compiled and loaded 0.0027 sec, 2.4 MiB
+ fenom: !compiled and !loaded 0.0093 sec, 3.0 MiB
+ fenom: compiled and !loaded 0.0033 sec, 2.4 MiB
+ fenom: compiled and loaded 0.0027 sec, 2.4 MiB
Inheriting of templates ({extends})
@@ -45,9 +45,9 @@ PHP 5.4.11
twig: compiled and !loaded 0.0255 sec, 6.3 MiB
twig: compiled and loaded 0.0038 sec, 6.3 MiB
- cytro: !compiled and !loaded 0.1222 sec, 3.9 MiB
- cytro: compiled and !loaded 0.0004 sec, 2.4 MiB
- cytro: compiled and loaded 0.0000 sec, 2.4 MiB
+ fenom: !compiled and !loaded 0.1222 sec, 3.9 MiB
+ fenom: compiled and !loaded 0.0004 sec, 2.4 MiB
+ fenom: compiled and loaded 0.0000 sec, 2.4 MiB
* **!compiled and !loaded** - template engine object created but parsers not initialized and templates not compiled
* **compiled and !loaded** - template engine object created, template compiled but not loaded
@@ -59,4 +59,4 @@ PHP 5.4.11
| --------------- | ------:| --------:| ------:|
| Smarty3 (3.1.13)| 320 | 190 | 55095 |
| Twig (1.13.0) | 162 | 131 | 13908 |
-| Cytro (1.0.1) | 9 | 16 | 3899 |
+| Fenom (1.0.1) | 9 | 16 | 3899 |
diff --git a/docs/ext/inheritance.md b/docs/ext/inheritance.md
index c9fa4a9..35f6380 100644
--- a/docs/ext/inheritance.md
+++ b/docs/ext/inheritance.md
@@ -31,19 +31,3 @@ Variant #2. Сloudy.
Variant #3. Rain.
Variant #4. Tornado.
-
-
-
-Error Info (x2) :
-Exception: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '839621621,839622021)' at line 1
-Query: SELECT `image_id`, `filename` FROM `s3_image_version` WHERE `format_id`=1 AND `image_id` IN (,839621621,839622021)
-#0 /www/oml.ru/s3/lib/class.db.php(480): Db::parseError('SELECT `image_i...')
-#1 /www/oml.ru/s3/forms/class.shop2.product.form.php(225): Db::query('SELECT `image_i...')
-#2 /www/oml.ru/s3/lib/class.form.php(2390): Shop2ProductForm->fillControls()
-#3 /www/oml.ru/s3/lib/class.form.php(1444): Form->execute()
-#4 /www/oml.ru/public/my/s3/data/shop2_product/edit.cphp(44): Form->display(Object(Smarty), 'form.ajax.tpl')
-#5 {main}
-
-Place: /www/oml.ru/s3/lib/class.db.php:607
-Time: 2013-06-05 03:54:51
-Url: http://agyumama.ru/my/s3/data/shop2_product/edit.cphp?shop_id=196421&ver_id=636664&access=u%3B270377&popup=1&product_id=89445221&rnd=9296&xhr=1
\ No newline at end of file
diff --git a/docs/ext/mods.md b/docs/ext/mods.md
index 8cf44b2..6695701 100644
--- a/docs/ext/mods.md
+++ b/docs/ext/mods.md
@@ -3,7 +3,7 @@
```
-$cytro->addModifier(string $modifier, callable $callback);
+$fenom->addModifier(string $modifier, callable $callback);
```
* `$modifier` - название модификатора, которое будет использоваться в шаблоне
@@ -16,7 +16,7 @@ For example:
```
```php
-$cytro->addModifier('my_modifier', function ($variable, $param1, $param2) {
+$fenom->addModifier('my_modifier', function ($variable, $param1, $param2) {
// ...
});
```
diff --git a/docs/ext/parsing.md b/docs/ext/parsing.md
index a62cd0f..8b79e0f 100644
--- a/docs/ext/parsing.md
+++ b/docs/ext/parsing.md
@@ -1,3 +1,9 @@
-Parsing templates
-=================
+Parsing templates [RU]
+======================
+
+### Tokenizer
+
+Объект Tokenizer содержит список готовых к обработке токенов и необходимые для фильтрации токенов методы. Помимо основнях констант расширения Tokenizer у объекта есть макросы, объединения, определенных токенов.
+
+### Parsers
diff --git a/docs/ext/provider.md b/docs/ext/provider.md
index 76aba85..a390796 100644
--- a/docs/ext/provider.md
+++ b/docs/ext/provider.md
@@ -1,3 +1,8 @@
-Add template provider
+Add template provider [RU]
=====================
+Источники шаблонов позволяют хранить шаблоны не только на файловой системе, а там где вам удобдно будет. Что бы указать откуда нужно взять шаблон используется схема в имени шаблона `db:page/about.tpl`, шаблон будет взят из источника `db`. Источник шаблонов добавляется через метод `addProvider`, при добавлении необходимо указать схему по которой можно запросить шаблон из этого источника:
+
+```php
+$fenom->addProvider("db", $db_provider);
+```
\ No newline at end of file
diff --git a/docs/ext/tags.md b/docs/ext/tags.md
index 3f76508..3ab24f6 100644
--- a/docs/ext/tags.md
+++ b/docs/ext/tags.md
@@ -11,15 +11,15 @@ Tags [RU]
Примитивное добавление функции можно осуществить следующим образом:
```php
-$cytro->addFunction(string $function_name, callable $callback[, callable $parser]);
+$fenom->addFunction(string $function_name, callable $callback[, callable $parser]);
```
В данном случае запускается стандартный парсер, который автоматически разберет аргументы тега, которые должны быть в формате HTML аттрибутов и отдаст их в функцию ассоциативным массивом.
-В данном случае вы можете переопределить парсер на произвольный в формате `function (Cytro\Tokenizer $tokenizer, Cytro\Template $template)`
+В данном случае вы можете переопределить парсер на произвольный в формате `function (Fenom\Tokenizer $tokenizer, Fenom\Template $template)`
Существует более совершенный способ добавления функции:
```php
-$cytro->addFunctionSmarty(string $function_name, callable $callback);
+$fenom->addFunctionSmarty(string $function_name, callable $callback);
```
В данном случае парсер просканирует список аргументов коллбека и попробует сопоставить с аргументами из тега. Таким образом вы успешно можете добавлять Ваши штатные функции.
@@ -29,7 +29,7 @@ $cytro->addFunctionSmarty(string $function_name, callable $callback);
Добавление блоковой функции аналогичен добавлению строковой за исключением того что есть возможность указать парсер для закрывающего тега.
```php
-$cytro->addBlockFunction(string $function_name, callable $callback[, callable $parser_open[, callable $parser_close]]);
+$fenom->addBlockFunction(string $function_name, callable $callback[, callable $parser_open[, callable $parser_close]]);
```
Сам коллбек принимает первым аргументом контент между открывающим и закрывающим тегом, а вторым аргументом - ассоциативный массив из аргуметов тега.
@@ -39,14 +39,14 @@ $cytro->addBlockFunction(string $function_name, callable $callback[, callable $p
Добавление строчного компилятора осуществляеться очень просто:
```php
-$cytro->addCompiler(string $compiler, callable $parser);
+$fenom->addCompiler(string $compiler, callable $parser);
```
-Парсер должен принимать `Cytro\Tokenizer $tokenizer`, `Cytro\Template $template` и возвращать PHP код.
+Парсер должен принимать `Fenom\Tokenizer $tokenizer`, `Fenom\Template $template` и возвращать PHP код.
Компилятор так же можно импортировать из класса автоматически
```php
-$cytro->addCompilerSmart(string $compiler, $storage);
+$fenom->addCompilerSmart(string $compiler, $storage);
```
`$storage` может быть как классом так и объектом. В данном случае шаблонизатор будет искать метод `tag{$compiler}`, который будет взят в качестве парсера тега.
@@ -56,13 +56,13 @@ $cytro->addCompilerSmart(string $compiler, $storage);
Добавление блочного компилятора осуществяется двум способами. Первый
```php
-$cytro->addBlockCompiler(string $compiler, array $parsers, array $tags);
+$fenom->addBlockCompiler(string $compiler, array $parsers, array $tags);
```
где `$parser` ассоциативный массив `["open" => parser, "close" => parser]`, сождержащий парсер на открывающий и на закрывающий тег, а `$tags` содержит список внутренних тегов в формате `["tag_name"] => parser`, которые могут быть использованы только с этим компилятором.
Второй способ добавления парсера через импортирование из класса или объекта методов:
```php
-$cytro->addBlockCompilerSmart(string $compiler, $storage, array $tags, array $floats);
+$fenom->addBlockCompilerSmart(string $compiler, $storage, array $tags, array $floats);
```
diff --git a/docs/install.md b/docs/install.md
index 4cfc6e6..892162c 100644
--- a/docs/install.md
+++ b/docs/install.md
@@ -5,11 +5,11 @@ For installation use [composer](http://getcompoer.org). Add in your `composer.js
```json
{
"require": {
- "bzick/cytro": "dev-master"
+ "bzick/fenom": "dev-master"
}
}
```
or use shell
-`composer require bzick/cytro`
+`composer require bzick/fenom`
-If you do not use composer - use `psr-0` format for loading Cytro's classes.
+If you do not use composer - use `psr-0` format for loading Fenom's classes.
diff --git a/docs/main.md b/docs/main.md
index 9b47e38..b20d256 100644
--- a/docs/main.md
+++ b/docs/main.md
@@ -1,10 +1,10 @@
Documentation
=============
-### Cytro
+### Fenom
-* [About](./about.md)
* [Install](./install.md)
+* [Usage](./usage.md)
* [Syntax](./syntax.md)
* [Settings](./settings.md)
* [Callbacks and filters](./callbacks.md)
@@ -47,7 +47,6 @@ Documentation
* [filter](./tags/filter.md)
* [ignore](./tags/ignore.md)
* [macro](./tags/macro.md) and `import`
-* [autotrim](./tags/autotrim.md)
* or [add](./ext/tags.md) your own
***
diff --git a/docs/settings.md b/docs/settings.md
index de85cff..d71c63f 100644
--- a/docs/settings.md
+++ b/docs/settings.md
@@ -6,31 +6,31 @@ Settings [RU]
Что бы установить папку для хранения кеша собранных шаблонов
```php
-$cytro->setCompileDir($dir);
+$fenom->setCompileDir($dir);
```
### Template settings
```php
// set options using factory
-$cytro = Cytro::factory($tpl_dir, $compile_dir, $options);
+$fenom = Fenom::factory($tpl_dir, $compile_dir, $options);
// or inline using method setOptions
-$cytro->setOptions($options);
+$fenom->setOptions($options);
```
Параметры могут быть массивом `'option_name' => true` (если ключ не указан автоматически задаётся false) или битовой маской.
-* **disable_methods**, `Cytro::DENY_METHODS`, запретить вызов методов у объектов
-* **disable_native_funcs**, `Cytro::DENY_INLINE_FUNCS`, запретить использование PHP функций, кроме разрешенных
-* **auto_reload**, `Cytro::AUTO_RELOAD`, пересобирать шаблон если его оригинал был изменён (замедляет работу шаблонизатора).
-* **force_compile**, `Cytro::FORCE_COMPILE`, пересобирать шаблон при каждом вызове (сильно замедляет работу шаблонизатора).
-* **force_include**, `Cytro::FORCE_INCLUDE`, оптимизировать вставку шаблона в шаблон. Это увеличит производительность и размер собранного шаблона.
+* **disable_methods**, `Fenom::DENY_METHODS`, запретить вызов методов у объектов
+* **disable_native_funcs**, `Fenom::DENY_INLINE_FUNCS`, запретить использование PHP функций, кроме разрешенных
+* **auto_reload**, `Fenom::AUTO_RELOAD`, пересобирать шаблон если его оригинал был изменён (замедляет работу шаблонизатора).
+* **force_compile**, `Fenom::FORCE_COMPILE`, пересобирать шаблон при каждом вызове (сильно замедляет работу шаблонизатора).
+* **force_include**, `Fenom::FORCE_INCLUDE`, оптимизировать вставку шаблона в шаблон. Это увеличит производительность и размер собранного шаблона.
```php
-$cytro->setOptions(array(
+$fenom->setOptions(array(
"compile_check" => true,
"force_include" => true
));
// same
-$cytro->setOptions(Cytro::AUTO_RELOAD | Cytro::FORCE_INCLUDE);
+$fenom->setOptions(Fenom::AUTO_RELOAD | Fenom::FORCE_INCLUDE);
```
\ No newline at end of file
diff --git a/docs/syntax.md b/docs/syntax.md
index db44cee..bff956a 100644
--- a/docs/syntax.md
+++ b/docs/syntax.md
@@ -1,7 +1,7 @@
Syntax [RU]
===========
-Cytro have [Smarty](http://www.smarty.net/) like syntax.
+Fenom have [Smarty](http://www.smarty.net/) like syntax.
## Variable
@@ -198,11 +198,11 @@ but if use single quote any template expressions will be on display as it is
### Ignoring temaplate code
-В шаблонизаторе Cytro используются фигурные скобки для отделения HTML от кода Cytro.
+В шаблонизаторе Fenom используются фигурные скобки для отделения HTML от кода Fenom.
Если требуется вывести текст, содержащий фигурные скобки, помните о следующих возможностях:
1. Использование блочного тега `{ignore}{/ignore}`. Текст внутри этого тега текст не компилируется шаблонизатором и выводится как есть.
-2. Если после открывающей фигурной скобки есть пробельный символ (пробел или `\t`) или перенос строки (`\r` или `\n`), то она не воспринимается как разделитель кода Cytro и код после неё выводится как есть.
+2. Если после открывающей фигурной скобки есть пробельный символ (пробел или `\t`) или перенос строки (`\r` или `\n`), то она не воспринимается как разделитель кода Fenom и код после неё выводится как есть.
Пример:
diff --git a/docs/tags/foreach.md b/docs/tags/foreach.md
index 20652af..8fde3f1 100644
--- a/docs/tags/foreach.md
+++ b/docs/tags/foreach.md
@@ -79,7 +79,7 @@ Tag {foreach} [RU]
{/foreach}
```
-В блоке `{foreachelse}...{/foreach}` использование `{break}`, `{continue}` выбросит исключение `Cytro\CompileException` при компиляции
+В блоке `{foreachelse}...{/foreach}` использование `{break}`, `{continue}` выбросит исключение `Fenom\CompileException` при компиляции
### Notice
diff --git a/docs/usage.md b/docs/usage.md
new file mode 100644
index 0000000..6e65c41
--- /dev/null
+++ b/docs/usage.md
@@ -0,0 +1,20 @@
+Basic usage
+===========
+
+### Creating template engine
+
+```php
+$fenom = Fenom::factory('/path/to/templates', '/path/to/template/cache', $options);
+
+//or
+
+$fenom = new Fenom(new FSProvider('/path/to/templates'));
+$fenom->setCompileDir('/path/to/template/cache');
+$fenom->setOptions($options);
+```
+
+### Output template result
+
+```php
+$fenom->display("template/name.tpl", $vars);
+```
\ No newline at end of file
diff --git a/src/Cytro/Compiler.php b/src/Cytro/Compiler.php
index d2957dd..764f3ab 100644
--- a/src/Cytro/Compiler.php
+++ b/src/Cytro/Compiler.php
@@ -1,20 +1,20 @@
parsePlainArg($tokens, $name);
$p = $tpl->parseParams($tokens);
if($p) { // if we have additionally variables
- if($name && ($tpl->getStorage()->getOptions() & \Cytro::FORCE_INCLUDE)) { // if FORCE_INCLUDE enabled and template name known
+ if($name && ($tpl->getStorage()->getOptions() & \Fenom::FORCE_INCLUDE)) { // if FORCE_INCLUDE enabled and template name known
$inc = $tpl->getStorage()->compile($name, false);
$tpl->addDepend($inc);
return '$_tpl = (array)$tpl; $tpl->exchangeArray('.self::toArray($p).'+$_tpl); ?>'.$inc->_body.'exchangeArray($_tpl); unset($_tpl);';
@@ -38,7 +38,7 @@ class Compiler {
return '$tpl->getStorage()->getTemplate('.$cname.')->display('.self::toArray($p).'+(array)$tpl);';
}
} else {
- if($name && ($tpl->getStorage()->getOptions() & \Cytro::FORCE_INCLUDE)) { // if FORCE_INCLUDE enabled and template name known
+ if($name && ($tpl->getStorage()->getOptions() & \Fenom::FORCE_INCLUDE)) { // if FORCE_INCLUDE enabled and template name known
$inc = $tpl->getStorage()->compile($name, false);
$tpl->addDepend($inc);
return '$_tpl = (array)$tpl; ?>'.$inc->_body.'exchangeArray($_tpl); unset($_tpl);';
@@ -399,7 +399,7 @@ class Compiler {
$tpl->_compatible = true;
}
$tpl->_extends = $tpl_name;
- return '$parent = $tpl->getStorage()->getTemplate('.$tpl_name.', \Cytro\Template::EXTENDED);';
+ return '$parent = $tpl->getStorage()->getTemplate('.$tpl_name.', \Fenom\Template::EXTENDED);';
}
}
@@ -416,7 +416,7 @@ class Compiler {
while(isset($t->_extends)) {
$t = $t->_extends;
if(is_object($t)) {
- /* @var \Cytro\Template $t */
+ /* @var \Fenom\Template $t */
$t->_extended = true;
$tpl->addDepend($t);
$t->_compatible = &$tpl->_compatible;
@@ -470,7 +470,7 @@ class Compiler {
return '?>'.$donor->getBody().'_compatible = true;
- return '$donor = $tpl->getStorage()->getTemplate('.$cname.', \Cytro\Template::EXTENDED);'.PHP_EOL.
+ return '$donor = $tpl->getStorage()->getTemplate('.$cname.', \Fenom\Template::EXTENDED);'.PHP_EOL.
'$donor->fetch((array)$tpl);'.PHP_EOL.
'$tpl->b += (array)$donor->b';
// throw new ImproperUseException('template name must be given explicitly');
diff --git a/src/Cytro/Modifier.php b/src/Cytro/Modifier.php
index fbe5616..06af1ec 100644
--- a/src/Cytro/Modifier.php
+++ b/src/Cytro/Modifier.php
@@ -1,13 +1,13 @@
_cytro = $cytro;
+ public function __construct(Fenom $fenom, \Closure $code, $props = array()) {
+ $this->_fenom = $fenom;
$props += self::$_props;
$this->_name = $props["name"];
- $this->_provider = $this->_cytro->getProvider($props["scm"]);
+ $this->_provider = $this->_fenom->getProvider($props["scm"]);
$this->_scm = $props["scm"];
$this->_time = $props["time"];
$this->_depends = $props["depends"];
@@ -84,10 +84,10 @@ class Render extends \ArrayObject {
/**
* Get template storage
- * @return Cytro
+ * @return Fenom
*/
public function getStorage() {
- return $this->_cytro;
+ return $this->_fenom;
}
public function getDepends() {
@@ -135,12 +135,12 @@ class Render extends \ArrayObject {
* @return bool
*/
public function isValid() {
- $provider = $this->_cytro->getProvider(strstr($this->_name, ":"), true);
+ $provider = $this->_fenom->getProvider(strstr($this->_name, ":"), true);
if($provider->getLastModified($this->_name) >= $this->_time) {
return false;
}
foreach($this->_depends as $tpl => $time) {
- if($this->_cytro->getTemplate($tpl)->getTime() !== $time) {
+ if($this->_fenom->getTemplate($tpl)->getTime() !== $time) {
return false;
}
}
diff --git a/src/Cytro/Scope.php b/src/Cytro/Scope.php
index 19f15b8..69ea05a 100644
--- a/src/Cytro/Scope.php
+++ b/src/Cytro/Scope.php
@@ -1,13 +1,13 @@
*/
class Template extends Render {
@@ -88,21 +88,21 @@ class Template extends Render {
/**
* Just factory
*
- * @param \Cytro $cytro
+ * @param \Fenom $fenom
* @param $options
* @return Template
*/
- public static function factory(Cytro $cytro, $options) {
- return new static($cytro, $options);
+ public static function factory(Fenom $fenom, $options) {
+ return new static($fenom, $options);
}
/**
- * @param Cytro $cytro Template storage
+ * @param Fenom $fenom Template storage
* @param int $options
- * @return \Cytro\Template
+ * @return \Fenom\Template
*/
- public function __construct(Cytro $cytro, $options) {
- $this->_cytro = $cytro;
+ public function __construct(Fenom $fenom, $options) {
+ $this->_fenom = $fenom;
$this->_options = $options;
}
@@ -120,7 +120,7 @@ class Template extends Render {
} else {
$this->_base_name = $name;
}
- $this->_provider = $this->_cytro->getProvider($provider);
+ $this->_provider = $this->_fenom->getProvider($provider);
$this->_src = $this->_provider->getSource($this->_base_name, $this->_time);
if($compile) {
$this->compile();
@@ -133,7 +133,7 @@ class Template extends Render {
* @param string $name template name
* @param string $src template source
* @param bool $compile
- * @return \Cytro\Template
+ * @return \Fenom\Template
*/
public function source($name, $src, $compile = true) {
$this->_name = $name;
@@ -177,7 +177,7 @@ class Template extends Render {
if($end === false) { // if unexpected end of template
throw new CompileException("Unclosed tag in line {$this->_line}", 0, 1, $this->_name, $this->_line);
}
- $tag = substr($this->_src, $start, $end - $start + 1); // variable $tag contains cytro tag '{...}'
+ $tag = substr($this->_src, $start, $end - $start + 1); // variable $tag contains fenom tag '{...}'
$_tag = substr($tag, 1, -1); // strip delimiters '{' and '}'
@@ -321,8 +321,8 @@ class Template extends Render {
*/
public function getTemplateCode() {
return "_name."' compiled at ".date('Y-m-d H:i:s')." */\n".
- "return new Cytro\\Render(\$cytro, ".$this->_getClosureSource().", ".var_export(array(
+ "/** Fenom template '".$this->_name."' compiled at ".date('Y-m-d H:i:s')." */\n".
+ "return new Fenom\\Render(\$fenom, ".$this->_getClosureSource().", ".var_export(array(
"options" => $this->_options,
"provider" => $this->_scm,
"name" => $this->_name,
@@ -466,20 +466,20 @@ class Template extends Render {
return $this->parseMacro($tokens, $name);
}
- if($act = $this->_cytro->getFunction($action)) { // call some function
+ if($act = $this->_fenom->getFunction($action)) { // call some function
switch($act["type"]) {
- case Cytro::BLOCK_COMPILER:
+ case Fenom::BLOCK_COMPILER:
$scope = new Scope($action, $this, $this->_line, $act, count($this->_stack), $this->_body);
$code = $scope->open($tokens);
if(!$scope->is_closed) {
array_push($this->_stack, $scope);
}
return $code;
- case Cytro::INLINE_COMPILER:
+ case Fenom::INLINE_COMPILER:
return call_user_func($act["parser"], $tokens, $this);
- case Cytro::INLINE_FUNCTION:
+ case Fenom::INLINE_FUNCTION:
return call_user_func($act["parser"], $act["function"], $tokens, $this);
- case Cytro::BLOCK_FUNCTION:
+ case Fenom::BLOCK_FUNCTION:
$scope = new Scope($action, $this, $this->_line, $act, count($this->_stack), $this->_body);
$scope->setFuncName($act["function"]);
array_push($this->_stack, $scope);
@@ -494,7 +494,7 @@ class Template extends Render {
return $this->_stack[$i]->tag($action, $tokens);
}
}
- if($tags = $this->_cytro->getTagOwners($action)) { // unknown template tag
+ if($tags = $this->_fenom->getTagOwners($action)) { // unknown template tag
throw new TokenizeException("Unexpected tag '$action' (this tag can be used with '".implode("', '", $tags)."')");
} else {
throw new TokenizeException("Unexpected tag $action");
@@ -548,7 +548,7 @@ class Template extends Render {
if($tokens->isSpecialVal()) {
$_exp .= $tokens->getAndNext();
} elseif($tokens->isNext("(")) {
- $func = $this->_cytro->getModifier($tokens->current());
+ $func = $this->_fenom->getModifier($tokens->current());
$tokens->next();
$_exp .= $func.$this->parseArgs($tokens);
} else {
@@ -687,7 +687,7 @@ class Template extends Render {
} elseif($t === T_OBJECT_OPERATOR) {
$prop = $tokens->getNext(T_STRING);
if($tokens->isNext("(")) {
- if($this->_options & Cytro::DENY_METHODS) {
+ if($this->_options & Fenom::DENY_METHODS) {
throw new \LogicException("Forbidden to call methods");
}
$pure_var = false;
@@ -844,7 +844,7 @@ class Template extends Render {
*/
public function parseModifier(Tokenizer $tokens, $value) {
while($tokens->is("|")) {
- $mods = $this->_cytro->getModifier( $modifier_name = $tokens->getNext(Tokenizer::MACRO_STRING) );
+ $mods = $this->_fenom->getModifier( $modifier_name = $tokens->getNext(Tokenizer::MACRO_STRING) );
$tokens->next();
$args = array();
diff --git a/src/Cytro/Tokenizer.php b/src/Cytro/Tokenizer.php
index b1bb35e..6b76d79 100644
--- a/src/Cytro/Tokenizer.php
+++ b/src/Cytro/Tokenizer.php
@@ -1,13 +1,13 @@
'strtoupper',
"lower" => 'strtolower',
"low" => 'strtolower',
- "date_format" => 'Cytro\Modifier::dateFormat',
- "date" => 'Cytro\Modifier::date',
- "truncate" => 'Cytro\Modifier::truncate',
- "escape" => 'Cytro\Modifier::escape',
- "e" => 'Cytro\Modifier::escape', // alias of escape
- "unescape" => 'Cytro\Modifier::unescape',
- "strip" => 'Cytro\Modifier::strip',
- "length" => 'Cytro\Modifier::length',
- "default" => 'Cytro\Modifier::defaultValue'
+ "date_format" => 'Fenom\Modifier::dateFormat',
+ "date" => 'Fenom\Modifier::date',
+ "truncate" => 'Fenom\Modifier::truncate',
+ "escape" => 'Fenom\Modifier::escape',
+ "e" => 'Fenom\Modifier::escape', // alias of escape
+ "unescape" => 'Fenom\Modifier::unescape',
+ "strip" => 'Fenom\Modifier::strip',
+ "length" => 'Fenom\Modifier::length',
+ "default" => 'Fenom\Modifier::defaultValue'
);
/**
@@ -112,137 +112,137 @@ class Cytro {
protected $_actions = array(
'foreach' => array( // {foreach ...} {break} {continue} {foreachelse} {/foreach}
'type' => self::BLOCK_COMPILER,
- 'open' => 'Cytro\Compiler::foreachOpen',
- 'close' => 'Cytro\Compiler::foreachClose',
+ 'open' => 'Fenom\Compiler::foreachOpen',
+ 'close' => 'Fenom\Compiler::foreachClose',
'tags' => array(
- 'foreachelse' => 'Cytro\Compiler::foreachElse',
- 'break' => 'Cytro\Compiler::tagBreak',
- 'continue' => 'Cytro\Compiler::tagContinue',
+ 'foreachelse' => 'Fenom\Compiler::foreachElse',
+ 'break' => 'Fenom\Compiler::tagBreak',
+ 'continue' => 'Fenom\Compiler::tagContinue',
),
'float_tags' => array('break' => 1, 'continue' => 1)
),
'if' => array( // {if ...} {elseif ...} {else} {/if}
'type' => self::BLOCK_COMPILER,
- 'open' => 'Cytro\Compiler::ifOpen',
- 'close' => 'Cytro\Compiler::stdClose',
+ 'open' => 'Fenom\Compiler::ifOpen',
+ 'close' => 'Fenom\Compiler::stdClose',
'tags' => array(
- 'elseif' => 'Cytro\Compiler::tagElseIf',
- 'else' => 'Cytro\Compiler::tagElse',
+ 'elseif' => 'Fenom\Compiler::tagElseIf',
+ 'else' => 'Fenom\Compiler::tagElse',
)
),
'switch' => array( // {switch ...} {case ...} {break} {default} {/switch}
'type' => self::BLOCK_COMPILER,
- 'open' => 'Cytro\Compiler::switchOpen',
- 'close' => 'Cytro\Compiler::stdClose',
+ 'open' => 'Fenom\Compiler::switchOpen',
+ 'close' => 'Fenom\Compiler::stdClose',
'tags' => array(
- 'case' => 'Cytro\Compiler::tagCase',
- 'default' => 'Cytro\Compiler::tagDefault',
- 'break' => 'Cytro\Compiler::tagBreak',
+ 'case' => 'Fenom\Compiler::tagCase',
+ 'default' => 'Fenom\Compiler::tagDefault',
+ 'break' => 'Fenom\Compiler::tagBreak',
),
'float_tags' => array('break' => 1)
),
'for' => array( // {for ...} {break} {continue} {/for}
'type' => self::BLOCK_COMPILER,
- 'open' => 'Cytro\Compiler::forOpen',
- 'close' => 'Cytro\Compiler::forClose',
+ 'open' => 'Fenom\Compiler::forOpen',
+ 'close' => 'Fenom\Compiler::forClose',
'tags' => array(
- 'forelse' => 'Cytro\Compiler::forElse',
- 'break' => 'Cytro\Compiler::tagBreak',
- 'continue' => 'Cytro\Compiler::tagContinue',
+ 'forelse' => 'Fenom\Compiler::forElse',
+ 'break' => 'Fenom\Compiler::tagBreak',
+ 'continue' => 'Fenom\Compiler::tagContinue',
),
'float_tags' => array('break' => 1, 'continue' => 1)
),
'while' => array( // {while ...} {break} {continue} {/while}
'type' => self::BLOCK_COMPILER,
- 'open' => 'Cytro\Compiler::whileOpen',
- 'close' => 'Cytro\Compiler::stdClose',
+ 'open' => 'Fenom\Compiler::whileOpen',
+ 'close' => 'Fenom\Compiler::stdClose',
'tags' => array(
- 'break' => 'Cytro\Compiler::tagBreak',
- 'continue' => 'Cytro\Compiler::tagContinue',
+ 'break' => 'Fenom\Compiler::tagBreak',
+ 'continue' => 'Fenom\Compiler::tagContinue',
),
'float_tags' => array('break' => 1, 'continue' => 1)
),
'include' => array( // {include ...}
'type' => self::INLINE_COMPILER,
- 'parser' => 'Cytro\Compiler::tagInclude'
+ 'parser' => 'Fenom\Compiler::tagInclude'
),
'var' => array( // {var ...}
'type' => self::BLOCK_COMPILER,
- 'open' => 'Cytro\Compiler::varOpen',
- 'close' => 'Cytro\Compiler::varClose'
+ 'open' => 'Fenom\Compiler::varOpen',
+ 'close' => 'Fenom\Compiler::varClose'
),
'block' => array( // {block ...} {parent} {/block}
'type' => self::BLOCK_COMPILER,
- 'open' => 'Cytro\Compiler::tagBlockOpen',
- 'close' => 'Cytro\Compiler::tagBlockClose',
+ 'open' => 'Fenom\Compiler::tagBlockOpen',
+ 'close' => 'Fenom\Compiler::tagBlockClose',
'tags' => array(
- 'parent' => 'Cytro\Compiler::tagParent'
+ 'parent' => 'Fenom\Compiler::tagParent'
),
'float_tags' => array('parent' => 1)
),
'extends' => array( // {extends ...}
'type' => self::INLINE_COMPILER,
- 'parser' => 'Cytro\Compiler::tagExtends'
+ 'parser' => 'Fenom\Compiler::tagExtends'
),
'use' => array( // {use}
'type' => self::INLINE_COMPILER,
- 'parser' => 'Cytro\Compiler::tagUse'
+ 'parser' => 'Fenom\Compiler::tagUse'
),
'capture' => array( // {capture ...} {/capture}
'type' => self::BLOCK_COMPILER,
- 'open' => 'Cytro\Compiler::captureOpen',
- 'close' => 'Cytro\Compiler::captureClose'
+ 'open' => 'Fenom\Compiler::captureOpen',
+ 'close' => 'Fenom\Compiler::captureClose'
),
'filter' => array( // {filter} ... {/filter}
'type' => self::BLOCK_COMPILER,
- 'open' => 'Cytro\Compiler::filterOpen',
- 'close' => 'Cytro\Compiler::filterClose'
+ 'open' => 'Fenom\Compiler::filterOpen',
+ 'close' => 'Fenom\Compiler::filterClose'
),
'macro' => array(
'type' => self::BLOCK_COMPILER,
- 'open' => 'Cytro\Compiler::macroOpen',
- 'close' => 'Cytro\Compiler::macroClose'
+ 'open' => 'Fenom\Compiler::macroOpen',
+ 'close' => 'Fenom\Compiler::macroClose'
),
'import' => array(
'type' => self::INLINE_COMPILER,
- 'parser' => 'Cytro\Compiler::tagImport'
+ 'parser' => 'Fenom\Compiler::tagImport'
),
'cycle' => array(
'type' => self::INLINE_COMPILER,
- 'parser' => 'Cytro\Compiler::tagCycle'
+ 'parser' => 'Fenom\Compiler::tagCycle'
)
);
/**
* Just factory
*
- * @param string|Cytro\ProviderInterface $source path to templates or custom provider
+ * @param string|Fenom\ProviderInterface $source path to templates or custom provider
* @param string $compile_dir path to compiled files
* @param int $options
* @throws InvalidArgumentException
- * @return Cytro
+ * @return Fenom
*/
public static function factory($source, $compile_dir = '/tmp', $options = 0) {
if(is_string($source)) {
- $provider = new Cytro\FSProvider($source);
+ $provider = new Fenom\Provider($source);
} elseif($source instanceof ProviderInterface) {
$provider = $source;
} else {
throw new InvalidArgumentException("Source must be a valid path or provider object");
}
- $cytro = new static($provider);
- /* @var Cytro $cytro */
- $cytro->setCompileDir($compile_dir);
+ $fenom = new static($provider);
+ /* @var Fenom $fytro */
+ $fenom->setCompileDir($compile_dir);
if($options) {
- $cytro->setOptions($options);
+ $fenom->setOptions($options);
}
- return $cytro;
+ return $fenom;
}
/**
- * @param Cytro\ProviderInterface $provider
+ * @param Fenom\ProviderInterface $provider
*/
- public function __construct(Cytro\ProviderInterface $provider) {
+ public function __construct(Fenom\ProviderInterface $provider) {
$this->_provider = $provider;
}
@@ -250,7 +250,7 @@ class Cytro {
* Set compile directory
*
* @param string $dir directory to store compiled templates in
- * @return Cytro
+ * @return Fenom
*/
public function setCompileDir($dir) {
$this->_compile_dir = $dir;
@@ -285,7 +285,7 @@ class Cytro {
*
* @param string $modifier the modifier name
* @param string $callback the modifier callback
- * @return Cytro
+ * @return Fenom
*/
public function addModifier($modifier, $callback) {
$this->_modifiers[$modifier] = $callback;
@@ -297,7 +297,7 @@ class Cytro {
*
* @param string $compiler
* @param callable $parser
- * @return Cytro
+ * @return Fenom
*/
public function addCompiler($compiler, $parser) {
$this->_actions[$compiler] = array(
@@ -329,7 +329,7 @@ class Cytro {
* @param callable $open_parser
* @param callable|string $close_parser
* @param array $tags
- * @return Cytro
+ * @return Fenom
*/
public function addBlockCompiler($compiler, $open_parser, $close_parser = self::DEFAULT_CLOSE_COMPILER, array $tags = array()) {
$this->_actions[$compiler] = array(
@@ -347,7 +347,7 @@ class Cytro {
* @param array $tags
* @param array $floats
* @throws LogicException
- * @return Cytro
+ * @return Fenom
*/
public function addBlockCompilerSmart($compiler, $storage, array $tags, array $floats = array()) {
$c = array(
@@ -383,7 +383,7 @@ class Cytro {
* @param string $function
* @param callable $callback
* @param callable|string $parser
- * @return Cytro
+ * @return Fenom
*/
public function addFunction($function, $callback, $parser = self::DEFAULT_FUNC_PARSER) {
$this->_actions[$function] = array(
@@ -397,7 +397,7 @@ class Cytro {
/**
* @param string $function
* @param callable $callback
- * @return Cytro
+ * @return Fenom
*/
public function addFunctionSmart($function, $callback) {
$this->_actions[$function] = array(
@@ -413,7 +413,7 @@ class Cytro {
* @param callable $callback
* @param callable|string $parser_open
* @param callable|string $parser_close
- * @return Cytro
+ * @return Fenom
*/
public function addBlockFunction($function, $callback, $parser_open = self::DEFAULT_FUNC_OPEN, $parser_close = self::DEFAULT_FUNC_CLOSE) {
$this->_actions[$function] = array(
@@ -427,7 +427,7 @@ class Cytro {
/**
* @param array $funcs
- * @return Cytro
+ * @return Fenom
*/
public function addAllowedFunctions(array $funcs) {
$this->_allowed_funcs = $this->_allowed_funcs + array_flip($funcs);
@@ -495,9 +495,9 @@ class Cytro {
* Add source template provider by scheme
*
* @param string $scm scheme name
- * @param Cytro\ProviderInterface $provider provider object
+ * @param Fenom\ProviderInterface $provider provider object
*/
- public function addProvider($scm, \Cytro\ProviderInterface $provider) {
+ public function addProvider($scm, \Fenom\ProviderInterface $provider) {
$this->_providers[$scm] = $provider;
}
@@ -528,7 +528,7 @@ class Cytro {
/**
* @param bool|string $scm
- * @return Cytro\ProviderInterface
+ * @return Fenom\ProviderInterface
* @throws InvalidArgumentException
*/
public function getProvider($scm = false) {
@@ -546,10 +546,10 @@ class Cytro {
/**
* Return empty template
*
- * @return Cytro\Template
+ * @return Fenom\Template
*/
public function getRawTemplate() {
- return new \Cytro\Template($this, $this->_options);
+ return new \Fenom\Template($this, $this->_options);
}
/**
@@ -557,7 +557,7 @@ class Cytro {
*
* @param string $template name of template
* @param array $vars array of data for template
- * @return Cytro\Render
+ * @return Fenom\Render
*/
public function display($template, array $vars = array()) {
return $this->getTemplate($template)->display($vars);
@@ -580,8 +580,8 @@ class Cytro {
* @param array $vars
* @param $callback
* @param float $chunk
- * @return \Cytro\Render
- * @example $cytro->pipe("products.yml.tpl", $iterators, [new SplFileObject("/tmp/products.yml"), "fwrite"], 512*1024)
+ * @return \Fenom\Render
+ * @example $fenom->pipe("products.yml.tpl", $iterators, [new SplFileObject("/tmp/products.yml"), "fwrite"], 512*1024)
*/
public function pipe($template, array $vars, $callback, $chunk = 1e6) {
ob_start($callback, $chunk, true);
@@ -595,12 +595,12 @@ class Cytro {
*
* @param string $template template name with schema
* @param int $options additional options and flags
- * @return Cytro\Template
+ * @return Fenom\Template
*/
public function getTemplate($template, $options = 0) {
$key = dechex($this->_options | $options)."@".$template;
if(isset($this->_storage[ $key ])) {
- /** @var Cytro\Template $tpl */
+ /** @var Fenom\Template $tpl */
$tpl = $this->_storage[ $key ];
if(($this->_options & self::AUTO_RELOAD) && !$tpl->isValid()) {
return $this->_storage[ $key ] = $this->compile($template, true, $options);
@@ -617,9 +617,9 @@ class Cytro {
/**
* Add custom template into storage
*
- * @param Cytro\Render $template
+ * @param Fenom\Render $template
*/
- public function addTemplate(Cytro\Render $template) {
+ public function addTemplate(Fenom\Render $template) {
$this->_storage[dechex($template->getOptions()).'@'. $template->getName() ] = $template;
}
@@ -628,14 +628,14 @@ class Cytro {
*
* @param string $tpl
* @param int $opts
- * @return Cytro\Render
+ * @return Fenom\Render
*/
protected function _load($tpl, $opts) {
$file_name = $this->_getCacheName($tpl, $opts);
if(!is_file($this->_compile_dir."/".$file_name)) {
return $this->compile($tpl, true, $opts);
} else {
- $cytro = $this;
+ $fenom = $this;
return include($this->_compile_dir."/".$file_name);
}
}
@@ -659,7 +659,7 @@ class Cytro {
* @param bool $store store template on disk
* @param int $options
* @throws RuntimeException
- * @return \Cytro\Template
+ * @return \Fenom\Template
*/
public function compile($tpl, $store = true, $options = 0) {
$options = $this->_options | $options;
@@ -692,7 +692,7 @@ class Cytro {
* Remove all compiled templates
*/
public function clearAllCompiles() {
- \Cytro\FSProvider::clean($this->_compile_dir);
+ \Fenom\Provider::clean($this->_compile_dir);
}
/**
@@ -700,7 +700,7 @@ class Cytro {
*
* @param string $code
* @param string $name
- * @return Cytro\Template
+ * @return Fenom\Template
*/
public function compileCode($code, $name = 'Runtime compile') {
return Template::factory($this, $this->_options)->source($name, $code);
diff --git a/tests/TestCase.php b/tests/TestCase.php
index 5c0e16e..6e19e6c 100644
--- a/tests/TestCase.php
+++ b/tests/TestCase.php
@@ -1,12 +1,12 @@
1,
@@ -18,14 +18,14 @@ class TestCase extends \PHPUnit_Framework_TestCase {
);
public function setUp() {
- if(!file_exists(CYTRO_RESOURCES.'/compile')) {
- mkdir(CYTRO_RESOURCES.'/compile', 0777, true);
+ if(!file_exists(FENOM_RESOURCES.'/compile')) {
+ mkdir(FENOM_RESOURCES.'/compile', 0777, true);
} else {
- FS::clean(CYTRO_RESOURCES.'/compile/');
+ FS::clean(FENOM_RESOURCES.'/compile/');
}
- $this->cytro = Cytro::factory(CYTRO_RESOURCES.'/template', CYTRO_RESOURCES.'/compile');
- $this->cytro->addModifier('dots', __CLASS__.'::dots');
- $this->cytro->addModifier('concat', __CLASS__.'::concat');
+ $this->fenom = Fenom::factory(FENOM_RESOURCES.'/template', FENOM_RESOURCES.'/compile');
+ $this->fenom->addModifier('dots', __CLASS__.'::dots');
+ $this->fenom->addModifier('concat', __CLASS__.'::concat');
}
public static function dots($value) {
@@ -37,15 +37,15 @@ class TestCase extends \PHPUnit_Framework_TestCase {
}
public static function setUpBeforeClass() {
- if(!file_exists(CYTRO_RESOURCES.'/template')) {
- mkdir(CYTRO_RESOURCES.'/template', 0777, true);
+ if(!file_exists(FENOM_RESOURCES.'/template')) {
+ mkdir(FENOM_RESOURCES.'/template', 0777, true);
} else {
- FS::clean(CYTRO_RESOURCES.'/template/');
+ FS::clean(FENOM_RESOURCES.'/template/');
}
}
public function tpl($name, $code) {
- file_put_contents(CYTRO_RESOURCES.'/template/'.$name, $code);
+ file_put_contents(FENOM_RESOURCES.'/template/'.$name, $code);
}
/**
@@ -57,7 +57,7 @@ class TestCase extends \PHPUnit_Framework_TestCase {
* @param bool $dump dump source and result code (for debug)
*/
public function exec($code, $vars, $result, $dump = false) {
- $tpl = $this->cytro->compileCode($code, "runtime.tpl");
+ $tpl = $this->fenom->compileCode($code, "runtime.tpl");
if($dump) {
echo "\n========= DUMP BEGIN ===========\n".$code."\n--- to ---\n".$tpl->getBody()."\n========= DUMP END =============\n";
}
@@ -66,7 +66,7 @@ class TestCase extends \PHPUnit_Framework_TestCase {
public function execTpl($name, $code, $vars, $result, $dump = false) {
$this->tpl($name, $code);
- $tpl = $this->cytro->getTemplate($name);
+ $tpl = $this->fenom->getTemplate($name);
if($dump) {
echo "\n========= DUMP BEGIN ===========\n".$code."\n--- to ---\n".$tpl->getBody()."\n========= DUMP END =============\n";
}
@@ -78,25 +78,25 @@ class TestCase extends \PHPUnit_Framework_TestCase {
* @param string $code source of the template
* @param string $exception exception class
* @param string $message exception message
- * @param int $options Cytro's options
+ * @param int $options Fenom's options
*/
public function execError($code, $exception, $message, $options = 0) {
- $opt = $this->cytro->getOptions();
- $this->cytro->setOptions($options);
+ $opt = $this->fenom->getOptions();
+ $this->fenom->setOptions($options);
try {
- $this->cytro->compileCode($code, "inline.tpl");
+ $this->fenom->compileCode($code, "inline.tpl");
} catch(\Exception $e) {
$this->assertSame($exception, get_class($e), "Exception $code");
$this->assertStringStartsWith($message, $e->getMessage());
- $this->cytro->setOptions($opt);
+ $this->fenom->setOptions($opt);
return;
}
- $this->cytro->setOptions($opt);
+ $this->fenom->setOptions($opt);
$this->fail("Code $code must be invalid");
}
public function assertRender($tpl, $result, $debug = false) {
- $template = $this->cytro->compileCode($tpl);
+ $template = $this->fenom->compileCode($tpl);
if($debug) {
print_r("$tpl:\n".$template->getBody());
}
diff --git a/tests/autoload.php b/tests/autoload.php
index 4a9db2c..a3691fd 100644
--- a/tests/autoload.php
+++ b/tests/autoload.php
@@ -4,9 +4,9 @@ require_once __DIR__."/../vendor/autoload.php";
-define('CYTRO_RESOURCES', __DIR__."/resources");
+define('FENOM_RESOURCES', __DIR__."/resources");
-require_once CYTRO_RESOURCES."/actions.php";
+require_once FENOM_RESOURCES."/actions.php";
require_once __DIR__."/TestCase.php";
function drop() {
diff --git a/tests/cases/CytroTest.php b/tests/cases/CytroTest.php
index 4cac804..956625d 100644
--- a/tests/cases/CytroTest.php
+++ b/tests/cases/CytroTest.php
@@ -1,22 +1,22 @@
cytro->addTemplate(new Render($this->cytro, function($tpl) use ($test) {
+ $this->fenom->addTemplate(new Render($this->fenom, function($tpl) use ($test) {
/** @var \PHPUnit_Framework_TestCase $test */
- $test->assertInstanceOf('Cytro\Render', $tpl);
+ $test->assertInstanceOf('Fenom\Render', $tpl);
echo "Inline render";
}, array(
"name" => 'render.tpl',
"scm" => false
)));
- $this->assertSame("Inline render", $this->cytro->fetch('render.tpl', array()));
+ $this->assertSame("Inline render", $this->fenom->fetch('render.tpl', array()));
}
public function testCompileFile() {
@@ -26,71 +26,71 @@ class CytroTest extends \Cytro\TestCase {
);
$this->tpl('template1.tpl', 'Template 1 a');
$this->tpl('template2.tpl', 'Template 2 b');
- $this->assertSame("Template 1 a", $this->cytro->fetch('template1.tpl', $a));
- $this->assertSame("Template 2 b", $this->cytro->fetch('template2.tpl', $a));
- $this->assertInstanceOf('Cytro\Render', $this->cytro->getTemplate('template1.tpl'));
- $this->assertInstanceOf('Cytro\Render', $this->cytro->getTemplate('template2.tpl'));
- $this->assertSame(3, iterator_count(new FilesystemIterator(CYTRO_RESOURCES.'/compile')));
+ $this->assertSame("Template 1 a", $this->fenom->fetch('template1.tpl', $a));
+ $this->assertSame("Template 2 b", $this->fenom->fetch('template2.tpl', $a));
+ $this->assertInstanceOf('Fenom\Render', $this->fenom->getTemplate('template1.tpl'));
+ $this->assertInstanceOf('Fenom\Render', $this->fenom->getTemplate('template2.tpl'));
+ $this->assertSame(3, iterator_count(new FilesystemIterator(FENOM_RESOURCES.'/compile')));
}
public function testStorage() {
$this->tpl('custom.tpl', 'Custom template');
- $this->assertSame("Custom template", $this->cytro->fetch('custom.tpl', array()));
- //$this->cytro->clearCompiledTemplate('custom.tpl', false);
+ $this->assertSame("Custom template", $this->fenom->fetch('custom.tpl', array()));
+ //$this->fenom->clearCompiledTemplate('custom.tpl', false);
- //$this->assertSame("Custom template", $this->cytro->fetch('custom.tpl', array()));
+ //$this->assertSame("Custom template", $this->fenom->fetch('custom.tpl', array()));
$this->tpl('custom.tpl', 'Custom template 2');
- $this->assertSame("Custom template", $this->cytro->fetch('custom.tpl', array()));
+ $this->assertSame("Custom template", $this->fenom->fetch('custom.tpl', array()));
}
public function testCheckMTime() {
- $this->cytro->setOptions(Cytro::FORCE_COMPILE);
+ $this->fenom->setOptions(Fenom::FORCE_COMPILE);
$this->tpl('custom.tpl', 'Custom template');
- $this->assertSame("Custom template", $this->cytro->fetch('custom.tpl', array()));
+ $this->assertSame("Custom template", $this->fenom->fetch('custom.tpl', array()));
sleep(1);
$this->tpl('custom.tpl', 'Custom template (new)');
- $this->assertSame("Custom template (new)", $this->cytro->fetch('custom.tpl', array()));
+ $this->assertSame("Custom template (new)", $this->fenom->fetch('custom.tpl', array()));
}
public function testForceCompile() {
- $this->cytro->setOptions(Cytro::FORCE_COMPILE);
+ $this->fenom->setOptions(Fenom::FORCE_COMPILE);
$this->tpl('custom.tpl', 'Custom template');
- $this->assertSame("Custom template", $this->cytro->fetch('custom.tpl', array()));
+ $this->assertSame("Custom template", $this->fenom->fetch('custom.tpl', array()));
$this->tpl('custom.tpl', 'Custom template (new)');
- $this->assertSame("Custom template (new)", $this->cytro->fetch('custom.tpl', array()));
+ $this->assertSame("Custom template (new)", $this->fenom->fetch('custom.tpl', array()));
}
public function testSetModifier() {
- $this->cytro->addModifier("mymod", "myMod");
+ $this->fenom->addModifier("mymod", "myMod");
$this->tpl('custom.tpl', 'Custom modifier {$a|mymod}');
- $this->assertSame("Custom modifier (myMod)Custom(/myMod)", $this->cytro->fetch('custom.tpl', array("a" => "Custom")));
+ $this->assertSame("Custom modifier (myMod)Custom(/myMod)", $this->fenom->fetch('custom.tpl', array("a" => "Custom")));
}
/**
* @group add_functions
*/
public function testSetFunctions() {
- $this->cytro->setOptions(Cytro::FORCE_COMPILE);
- $this->cytro->addFunction("myfunc", "myFunc");
- $this->cytro->addBlockFunction("myblockfunc", "myBlockFunc");
+ $this->fenom->setOptions(Fenom::FORCE_COMPILE);
+ $this->fenom->addFunction("myfunc", "myFunc");
+ $this->fenom->addBlockFunction("myblockfunc", "myBlockFunc");
$this->tpl('custom.tpl', 'Custom function {myfunc name="foo"}');
- $this->assertSame("Custom function MyFunc:foo", $this->cytro->fetch('custom.tpl', array()));
+ $this->assertSame("Custom function MyFunc:foo", $this->fenom->fetch('custom.tpl', array()));
$this->tpl('custom.tpl', 'Custom function {myblockfunc name="foo"} this block1 {/myblockfunc}');
- $this->assertSame("Custom function Block:foo:this block1:Block", $this->cytro->fetch('custom.tpl', array()));
+ $this->assertSame("Custom function Block:foo:this block1:Block", $this->fenom->fetch('custom.tpl', array()));
}
public function testSetCompilers() {
- $this->cytro->setOptions(Cytro::FORCE_COMPILE);
- $this->cytro->addCompiler("mycompiler", 'myCompiler');
- $this->cytro->addBlockCompiler("myblockcompiler", 'myBlockCompilerOpen', 'myBlockCompilerClose', array(
+ $this->fenom->setOptions(Fenom::FORCE_COMPILE);
+ $this->fenom->addCompiler("mycompiler", 'myCompiler');
+ $this->fenom->addBlockCompiler("myblockcompiler", 'myBlockCompilerOpen', 'myBlockCompilerClose', array(
'tag' => 'myBlockCompilerTag'
));
$this->tpl('custom.tpl', 'Custom compiler {mycompiler name="bar"}');
- $this->assertSame("Custom compiler PHP_VERSION: ".PHP_VERSION." (for bar)", $this->cytro->fetch('custom.tpl', array()));
+ $this->assertSame("Custom compiler PHP_VERSION: ".PHP_VERSION." (for bar)", $this->fenom->fetch('custom.tpl', array()));
$this->tpl('custom.tpl', 'Custom compiler {myblockcompiler name="bar"} block1 {tag name="baz"} block2 {/myblockcompiler}');
- $this->assertSame("Custom compiler PHP_VERSION: ".PHP_VERSION." (for bar) block1 Tag baz of compiler block2 End of compiler", $this->cytro->fetch('custom.tpl', array()));
+ $this->assertSame("Custom compiler PHP_VERSION: ".PHP_VERSION." (for bar) block1 Tag baz of compiler block2 End of compiler", $this->fenom->fetch('custom.tpl', array()));
}
}
diff --git a/tests/cases/Cytro/CommentTest.php b/tests/cases/Fenom/CommentTest.php
similarity index 97%
rename from tests/cases/Cytro/CommentTest.php
rename to tests/cases/Fenom/CommentTest.php
index 19e34e1..a676e1b 100644
--- a/tests/cases/Cytro/CommentTest.php
+++ b/tests/cases/Fenom/CommentTest.php
@@ -1,6 +1,6 @@
cytro->addProvider("my", new FSProvider(CYTRO_RESOURCES.'/provider'));
+ $this->fenom->addProvider("my", new Provider(FENOM_RESOURCES.'/provider'));
}
public function testCustom() {
diff --git a/tests/cases/Cytro/ExtendsTemplateTest.php b/tests/cases/Fenom/ExtendsTemplateTest.php
similarity index 87%
rename from tests/cases/Cytro/ExtendsTemplateTest.php
rename to tests/cases/Fenom/ExtendsTemplateTest.php
index 3a61dcb..4b43f6d 100644
--- a/tests/cases/Cytro/ExtendsTemplateTest.php
+++ b/tests/cases/Fenom/ExtendsTemplateTest.php
@@ -1,13 +1,13 @@
cytro = Cytro::factory(CYTRO_RESOURCES.'/provider', CYTRO_RESOURCES.'/compile');
+ $this->fenom = Fenom::factory(FENOM_RESOURCES.'/provider', FENOM_RESOURCES.'/compile');
try {
- print_r($this->cytro->getTemplate('use/child.tpl')->getBody());
+ print_r($this->fenom->getTemplate('use/child.tpl')->getBody());
} catch (\Exception $e) {
echo "$e";
}
@@ -114,24 +114,24 @@ class ExtendsTemplateTest extends TestCase {
$tpls = self::generate('{block "%s"}%s{/block}', '{extends "level.%d.tpl"}', self::templates($vars));
foreach($tpls as $name => $tpl) {
$this->tpl($name, $tpl["src"]);
- $this->assertSame($this->cytro->fetch($name, $vars), $tpl["dst"]);
+ $this->assertSame($this->fenom->fetch($name, $vars), $tpl["dst"]);
}
return;
$vars["default"]++;
- $this->cytro->flush();
+ $this->fenom->flush();
$tpls = self::generate('{block "{$%s}"}%s{/block}', '{extends "level.%d.tpl"}', self::templates($vars));
arsort($tpls);
foreach($tpls as $name => $tpl) {
$this->tpl("d.".$name, $tpl["src"]);
- $this->assertSame($this->cytro->fetch("d.".$name, $vars), $tpl["dst"]);
+ $this->assertSame($this->fenom->fetch("d.".$name, $vars), $tpl["dst"]);
}
$vars["default"]++;
- $this->cytro->flush();
+ $this->fenom->flush();
$tpls = self::generate('{block "%s"}%s{/block}', '{extends "$level.%d.tpl"}', self::templates($vars));
arsort($tpls);
foreach($tpls as $name => $tpl) {
$this->tpl("x.".$name, $tpl["src"]);
- $this->assertSame($this->cytro->fetch("x.".$name, $vars), $tpl["dst"]);
+ $this->assertSame($this->fenom->fetch("x.".$name, $vars), $tpl["dst"]);
}
}
@@ -139,8 +139,8 @@ class ExtendsTemplateTest extends TestCase {
* @group use
*/
public function testUse() {
- $this->cytro = Cytro::factory(CYTRO_RESOURCES.'/provider', CYTRO_RESOURCES.'/compile');
- $this->assertSame("\n block 1 blocks \n block 2 child \n", $this->cytro->fetch('use/child.tpl'));
+ $this->fenom = Fenom::factory(FENOM_RESOURCES.'/provider', FENOM_RESOURCES.'/compile');
+ $this->assertSame("\n block 1 blocks \n block 2 child \n", $this->fenom->fetch('use/child.tpl'));
}
public function _testParent() {
diff --git a/tests/cases/Cytro/MacrosTest.php b/tests/cases/Fenom/MacrosTest.php
similarity index 86%
rename from tests/cases/Cytro/MacrosTest.php
rename to tests/cases/Fenom/MacrosTest.php
index f40c0c5..ded0bb9 100644
--- a/tests/cases/Cytro/MacrosTest.php
+++ b/tests/cases/Fenom/MacrosTest.php
@@ -1,5 +1,5 @@
cytro->compile('math.tpl');
+ $tpl = $this->fenom->compile('math.tpl');
$this->assertStringStartsWith('x + y = ', trim($tpl->macros["plus"]["body"]));
$this->assertSame('Math: x + y = 5 , x - y - z = 6', Modifier::strip($tpl->fetch(array()), true));
}
public function testImport() {
- $tpl = $this->cytro->compile('import.tpl');
+ $tpl = $this->fenom->compile('import.tpl');
$this->assertSame('Imp: x + y = 3 , x - y - z = 3', Modifier::strip($tpl->fetch(array()), true));
}
public function testImportCustom() {
- $tpl = $this->cytro->compile('import_custom.tpl');
+ $tpl = $this->fenom->compile('import_custom.tpl');
$this->assertSame('a: x + y = 3 , x - y - z = 3 , new minus macros .', Modifier::strip($tpl->fetch(array()), true));
}
/**
* @expectedExceptionMessage Undefined macro 'plus'
- * @expectedException \Cytro\CompileException
+ * @expectedException \Fenom\CompileException
*/
public function testImportMiss() {
- $tpl = $this->cytro->compile('import_miss.tpl');
+ $tpl = $this->fenom->compile('import_miss.tpl');
$this->assertSame('a: x + y = 3 , x - y - z = 3 , new minus macros .', Modifier::strip($tpl->fetch(array()), true));
}
diff --git a/tests/cases/Cytro/ModifiersTest.php b/tests/cases/Fenom/ModifiersTest.php
similarity index 93%
rename from tests/cases/Cytro/ModifiersTest.php
rename to tests/cases/Fenom/ModifiersTest.php
index d86a58e..abf21ef 100644
--- a/tests/cases/Cytro/ModifiersTest.php
+++ b/tests/cases/Fenom/ModifiersTest.php
@@ -1,5 +1,5 @@
cytro->compileCode('{$text|truncate:$count:$delim:$by_words:$middle}');
+ $tpl = $this->fenom->compileCode('{$text|truncate:$count:$delim:$by_words:$middle}');
$this->assertEquals($out, $tpl->fetch(array(
"text" => $in,
"count" => $count,
@@ -65,7 +65,7 @@ class ModifiersTest extends TestCase {
* @param $out
*/
public function testUpLow($modifier, $in, $out) {
- $tpl = $this->cytro->compileCode('{$text|'.$modifier.'}');
+ $tpl = $this->fenom->compileCode('{$text|'.$modifier.'}');
$this->assertEquals($out, $tpl->fetch(array(
"text" => $in,
)));
@@ -91,7 +91,7 @@ class ModifiersTest extends TestCase {
* @param $out
*/
public function testLength($in, $out) {
- $tpl = $this->cytro->compileCode('{$data|length}');
+ $tpl = $this->fenom->compileCode('{$data|length}');
$this->assertEquals($out, $tpl->fetch(array(
"data" => $in,
)));
diff --git a/tests/cases/Cytro/ProviderTest.php b/tests/cases/Fenom/ProviderTest.php
similarity index 79%
rename from tests/cases/Cytro/ProviderTest.php
rename to tests/cases/Fenom/ProviderTest.php
index 241d02e..c62fb16 100644
--- a/tests/cases/Cytro/ProviderTest.php
+++ b/tests/cases/Fenom/ProviderTest.php
@@ -1,10 +1,10 @@
tpl("template1.tpl", 'Template 1 {$a}');
$this->tpl("template2.tpl", 'Template 2 {$a}');
- $this->provider = new FSProvider(CYTRO_RESOURCES.'/template');
+ $this->provider = new Provider(FENOM_RESOURCES.'/template');
}
public function testIsTemplateExists() {
@@ -23,8 +23,8 @@ class FSProviderTest extends \Cytro\TestCase {
public function testGetSource() {
$src = $this->provider->getSource("template1.tpl", $time);
clearstatcache();
- $this->assertEquals(file_get_contents(CYTRO_RESOURCES.'/template/template1.tpl'), $src);
- $this->assertEquals(filemtime(CYTRO_RESOURCES.'/template/template1.tpl'), $time);
+ $this->assertEquals(file_get_contents(FENOM_RESOURCES.'/template/template1.tpl'), $src);
+ $this->assertEquals(filemtime(FENOM_RESOURCES.'/template/template1.tpl'), $time);
}
/**
@@ -37,7 +37,7 @@ class FSProviderTest extends \Cytro\TestCase {
public function testGetLastModified() {
$time = $this->provider->getLastModified("template1.tpl");
clearstatcache();
- $this->assertEquals(filemtime(CYTRO_RESOURCES.'/template/template1.tpl'), $time);
+ $this->assertEquals(filemtime(FENOM_RESOURCES.'/template/template1.tpl'), $time);
}
/**
@@ -52,7 +52,7 @@ class FSProviderTest extends \Cytro\TestCase {
$this->assertSame($tpls, array_keys($times));
clearstatcache();
foreach($times as $template => $time) {
- $this->assertEquals(filemtime(CYTRO_RESOURCES."/template/$template"), $time);
+ $this->assertEquals(filemtime(FENOM_RESOURCES."/template/$template"), $time);
}
}
diff --git a/tests/cases/Cytro/RenderTest.php b/tests/cases/Fenom/RenderTest.php
similarity index 84%
rename from tests/cases/Cytro/RenderTest.php
rename to tests/cases/Fenom/RenderTest.php
index 6ec1134..8d1c7c1 100644
--- a/tests/cases/Cytro/RenderTest.php
+++ b/tests/cases/Fenom/RenderTest.php
@@ -1,7 +1,7 @@
"render.tpl"
@@ -19,7 +19,7 @@ class RenderTest extends \PHPUnit_Framework_TestCase {
}
public function testCreate() {
- $r = new Render(Cytro::factory("."), function () {
+ $r = new Render(Fenom::factory("."), function () {
echo "Test render";
}, array(
"name" => "test.render.tpl"
@@ -43,7 +43,7 @@ class RenderTest extends \PHPUnit_Framework_TestCase {
* @expectedExceptionMessage template error
*/
public function testFetchException() {
- $render = new Render(Cytro::factory("."), function () {
+ $render = new Render(Fenom::factory("."), function () {
echo "error";
throw new \RuntimeException("template error");
}, array(
diff --git a/tests/cases/Cytro/ScopeTest.php b/tests/cases/Fenom/ScopeTest.php
similarity index 71%
rename from tests/cases/Cytro/ScopeTest.php
rename to tests/cases/Fenom/ScopeTest.php
index 2205aa8..2018459 100644
--- a/tests/cases/Cytro/ScopeTest.php
+++ b/tests/cases/Fenom/ScopeTest.php
@@ -1,23 +1,23 @@
assertInstanceOf('Cytro\Tokenizer', $tokenizer);
- $this->assertInstanceOf('Cytro\Scope', $scope);
+ $this->assertInstanceOf('Fenom\Tokenizer', $tokenizer);
+ $this->assertInstanceOf('Fenom\Scope', $scope);
$scope["value"] = true;
return "open-tag";
}
public function closeTag($tokenizer, $scope) {
- $this->assertInstanceOf('Cytro\Tokenizer', $tokenizer);
- $this->assertInstanceOf('Cytro\Scope', $scope);
+ $this->assertInstanceOf('Fenom\Tokenizer', $tokenizer);
+ $this->assertInstanceOf('Fenom\Scope', $scope);
$this->assertTrue($scope["value"]);
return "close-tag";
}
public function testBlock() {
- /*$scope = new Scope($this->cytro, new Template($this->cytro), 1, array(
+ /*$scope = new Scope($this->fenom, new Template($this->fenom), 1, array(
"open" => array($this, "openTag"),
"close" => array($this, "closeTag")
), 0);
diff --git a/tests/cases/Cytro/TagsTest.php b/tests/cases/Fenom/TagsTest.php
similarity index 94%
rename from tests/cases/Cytro/TagsTest.php
rename to tests/cases/Fenom/TagsTest.php
index 371afd3..61ada8c 100644
--- a/tests/cases/Cytro/TagsTest.php
+++ b/tests/cases/Fenom/TagsTest.php
@@ -1,13 +1,13 @@
cytro->compileCode('{for $i=0 to=5}{cycle ["one", "two"]}, {/for}')->getBody());
+ var_dump($this->fenom->compileCode('{for $i=0 to=5}{cycle ["one", "two"]}, {/for}')->getBody());
} catch(\Exception $e) {
echo "$e";
}
diff --git a/tests/cases/Cytro/TemplateTest.php b/tests/cases/Fenom/TemplateTest.php
similarity index 86%
rename from tests/cases/Cytro/TemplateTest.php
rename to tests/cases/Fenom/TemplateTest.php
index a601331..0946eee 100644
--- a/tests/cases/Cytro/TemplateTest.php
+++ b/tests/cases/Fenom/TemplateTest.php
@@ -1,19 +1,19 @@
cytro->addTemplate(new Render($this->cytro, function ($tpl) {
+ $this->fenom->addTemplate(new Render($this->fenom, function ($tpl) {
echo "Welcome, ".$tpl["username"]." (".$tpl["email"].")";
}, array(
"name" => "welcome.tpl"
@@ -76,14 +76,14 @@ class TemplateTest extends TestCase {
public static function providerVarsInvalid() {
return array(
- array('hello, {$a.}!', 'Cytro\CompileException', "Unexpected end of expression"),
- array('hello, {$b[c}!', 'Cytro\CompileException', "Unexpected end of expression"),
- array('hello, {$b.c]}!', 'Cytro\CompileException', "Unexpected token ']'"),
- array('hello, {$b[ ]}!', 'Cytro\CompileException', "Unexpected token ']'"),
- array('hello, {$b[9/].c}!', 'Cytro\CompileException', "Unexpected token ']'"),
- array('hello, {$b[3]$c}!', 'Cytro\CompileException', "Unexpected token '\$c'"),
- array('hello, {$b[3]c}!', 'Cytro\CompileException', "Unexpected token 'c'"),
- array('hello, {$b.obj->valid()}!', 'Cytro\SecurityException', "Forbidden to call methods", Cytro::DENY_METHODS),
+ array('hello, {$a.}!', 'Fenom\CompileException', "Unexpected end of expression"),
+ array('hello, {$b[c}!', 'Fenom\CompileException', "Unexpected end of expression"),
+ array('hello, {$b.c]}!', 'Fenom\CompileException', "Unexpected token ']'"),
+ array('hello, {$b[ ]}!', 'Fenom\CompileException', "Unexpected token ']'"),
+ array('hello, {$b[9/].c}!', 'Fenom\CompileException', "Unexpected token ']'"),
+ array('hello, {$b[3]$c}!', 'Fenom\CompileException', "Unexpected token '\$c'"),
+ array('hello, {$b[3]c}!', 'Fenom\CompileException', "Unexpected token 'c'"),
+ array('hello, {$b.obj->valid()}!', 'Fenom\SecurityException', "Forbidden to call methods", Fenom::DENY_METHODS),
);
}
@@ -138,12 +138,12 @@ class TemplateTest extends TestCase {
public static function providerModifiersInvalid() {
return array(
- array('Mod: {$lorem|}!', 'Cytro\CompileException', "Unexpected end of expression"),
- array('Mod: {$lorem|str_rot13}!', 'Cytro\CompileException', "Modifier str_rot13 not found", Cytro::DENY_INLINE_FUNCS),
- array('Mod: {$lorem|my_encode}!', 'Cytro\CompileException', "Modifier my_encode not found"),
- array('Mod: {$lorem|truncate:}!', 'Cytro\CompileException', "Unexpected end of expression"),
- array('Mod: {$lorem|truncate:abs}!', 'Cytro\CompileException', "Unexpected token 'abs'"),
- array('Mod: {$lorem|truncate:80|}!', 'Cytro\CompileException', "Unexpected end of expression"),
+ array('Mod: {$lorem|}!', 'Fenom\CompileException', "Unexpected end of expression"),
+ array('Mod: {$lorem|str_rot13}!', 'Fenom\CompileException', "Modifier str_rot13 not found", Fenom::DENY_INLINE_FUNCS),
+ array('Mod: {$lorem|my_encode}!', 'Fenom\CompileException', "Modifier my_encode not found"),
+ array('Mod: {$lorem|truncate:}!', 'Fenom\CompileException', "Unexpected end of expression"),
+ array('Mod: {$lorem|truncate:abs}!', 'Fenom\CompileException', "Unexpected token 'abs'"),
+ array('Mod: {$lorem|truncate:80|}!', 'Fenom\CompileException', "Unexpected end of expression"),
);
}
@@ -185,15 +185,15 @@ class TemplateTest extends TestCase {
public static function providerExpressionsInvalid() {
return array(
- array('If: {-"hi"} end', 'Cytro\CompileException', "Unexpected token '-'"),
- array('If: {($a++)++} end', 'Cytro\CompileException', "Unexpected token '++'"),
- array('If: {$a + * $c} end', 'Cytro\CompileException', "Unexpected token '*'"),
- array('If: {/$a} end', 'Cytro\CompileException', "Unexpected token '\$a'"),
- array('If: {$a == 5 > 4} end', 'Cytro\CompileException', "Unexpected token '>'"),
- array('If: {$a != 5 <= 4} end', 'Cytro\CompileException', "Unexpected token '<='"),
- array('If: {$a != 5 => 4} end', 'Cytro\CompileException', "Unexpected token '=>'"),
- array('If: {$a + (*6)} end', 'Cytro\CompileException', "Unexpected token '*'"),
- array('If: {$a + ( 6} end', 'Cytro\CompileException', "Brackets don't match"),
+ array('If: {-"hi"} end', 'Fenom\CompileException', "Unexpected token '-'"),
+ array('If: {($a++)++} end', 'Fenom\CompileException', "Unexpected token '++'"),
+ array('If: {$a + * $c} end', 'Fenom\CompileException', "Unexpected token '*'"),
+ array('If: {/$a} end', 'Fenom\CompileException', "Unexpected token '\$a'"),
+ array('If: {$a == 5 > 4} end', 'Fenom\CompileException', "Unexpected token '>'"),
+ array('If: {$a != 5 <= 4} end', 'Fenom\CompileException', "Unexpected token '<='"),
+ array('If: {$a != 5 => 4} end', 'Fenom\CompileException', "Unexpected token '=>'"),
+ array('If: {$a + (*6)} end', 'Fenom\CompileException', "Unexpected token '*'"),
+ array('If: {$a + ( 6} end', 'Fenom\CompileException', "Brackets don't match"),
);
}
@@ -230,8 +230,8 @@ class TemplateTest extends TestCase {
public static function providerIncludeInvalid() {
return array(
- array('Include {include} template', 'Cytro\CompileException', "Unexpected end of expression"),
- array('Include {include another="welcome.tpl"} template', 'Cytro\CompileException', "Unexpected token '='"),
+ array('Include {include} template', 'Fenom\CompileException', "Unexpected end of expression"),
+ array('Include {include another="welcome.tpl"} template', 'Fenom\CompileException', "Unexpected token '='"),
);
}
@@ -271,10 +271,10 @@ class TemplateTest extends TestCase {
public static function providerIfInvalid() {
return array(
- array('If: {if} block1 {/if} end', 'Cytro\CompileException', "Unexpected end of expression"),
- array('If: {if 1} block1 {elseif} block2 {/if} end', 'Cytro\CompileException', "Unexpected end of expression"),
- array('If: {if 1} block1 {else} block2 {elseif 0} block3 {/if} end', 'Cytro\CompileException', "Incorrect use of the tag {elseif}"),
- array('If: {if 1} block1 {else} block2 {/if} block3 {elseif 0} end', 'Cytro\CompileException', "Unexpected tag 'elseif' (this tag can be used with 'if')"),
+ array('If: {if} block1 {/if} end', 'Fenom\CompileException', "Unexpected end of expression"),
+ array('If: {if 1} block1 {elseif} block2 {/if} end', 'Fenom\CompileException', "Unexpected end of expression"),
+ array('If: {if 1} block1 {else} block2 {elseif 0} block3 {/if} end', 'Fenom\CompileException', "Incorrect use of the tag {elseif}"),
+ array('If: {if 1} block1 {else} block2 {/if} block3 {elseif 0} end', 'Fenom\CompileException', "Unexpected tag 'elseif' (this tag can be used with 'if')"),
);
}
@@ -312,20 +312,20 @@ class TemplateTest extends TestCase {
public static function providerCreateVarInvalid() {
return array(
- array('Create: {var $v} Result: {$v} end', 'Cytro\CompileException', "Unclosed tag: {var} opened"),
- array('Create: {var $v = } Result: {$v} end', 'Cytro\CompileException', "Unexpected end of expression"),
- array('Create: {var $v = 1++} Result: {$v} end', 'Cytro\CompileException', "Unexpected token '++'"),
- array('Create: {var $v = c} Result: {$v} end', 'Cytro\CompileException', "Unexpected token 'c'"),
- array('Create: {var $v = ($a)++} Result: {$v} end', 'Cytro\CompileException', "Unexpected token '++'"),
- array('Create: {var $v = --$a++} Result: {$v} end', 'Cytro\CompileException', "Unexpected token '++'"),
- array('Create: {var $v = $a|upper++} Result: {$v} end', 'Cytro\CompileException', "Unexpected token '++'"),
- array('Create: {var $v = max($a,2)++} Result: {$v} end', 'Cytro\CompileException', "Unexpected token '++'"),
- array('Create: {var $v = max($a,2)} Result: {$v} end', 'Cytro\CompileException', "Modifier max not found", Cytro::DENY_INLINE_FUNCS),
- array('Create: {var $v = 4*} Result: {$v} end', 'Cytro\CompileException', "Unexpected token '*'"),
- array('Create: {var $v = ""$a} Result: {$v} end', 'Cytro\CompileException', "Unexpected token '\$a'"),
- array('Create: {var $v = [1,2} Result: {$v} end', 'Cytro\CompileException', "Unexpected end of expression"),
- array('Create: {var $v = empty(2)} Result: {$v} end', 'Cytro\CompileException', "Unexpected token 2, isset() and empty() accept only variables"),
- array('Create: {var $v = isset(2)} Result: {$v} end', 'Cytro\CompileException', "Unexpected token 2, isset() and empty() accept only variables"),
+ array('Create: {var $v} Result: {$v} end', 'Fenom\CompileException', "Unclosed tag: {var} opened"),
+ array('Create: {var $v = } Result: {$v} end', 'Fenom\CompileException', "Unexpected end of expression"),
+ array('Create: {var $v = 1++} Result: {$v} end', 'Fenom\CompileException', "Unexpected token '++'"),
+ array('Create: {var $v = c} Result: {$v} end', 'Fenom\CompileException', "Unexpected token 'c'"),
+ array('Create: {var $v = ($a)++} Result: {$v} end', 'Fenom\CompileException', "Unexpected token '++'"),
+ array('Create: {var $v = --$a++} Result: {$v} end', 'Fenom\CompileException', "Unexpected token '++'"),
+ array('Create: {var $v = $a|upper++} Result: {$v} end', 'Fenom\CompileException', "Unexpected token '++'"),
+ array('Create: {var $v = max($a,2)++} Result: {$v} end', 'Fenom\CompileException', "Unexpected token '++'"),
+ array('Create: {var $v = max($a,2)} Result: {$v} end', 'Fenom\CompileException', "Modifier max not found", Fenom::DENY_INLINE_FUNCS),
+ array('Create: {var $v = 4*} Result: {$v} end', 'Fenom\CompileException', "Unexpected token '*'"),
+ array('Create: {var $v = ""$a} Result: {$v} end', 'Fenom\CompileException', "Unexpected token '\$a'"),
+ array('Create: {var $v = [1,2} Result: {$v} end', 'Fenom\CompileException', "Unexpected end of expression"),
+ array('Create: {var $v = empty(2)} Result: {$v} end', 'Fenom\CompileException', "Unexpected token 2, isset() and empty() accept only variables"),
+ array('Create: {var $v = isset(2)} Result: {$v} end', 'Fenom\CompileException', "Unexpected token 2, isset() and empty() accept only variables"),
);
}
@@ -418,27 +418,27 @@ class TemplateTest extends TestCase {
public static function providerForeachInvalid() {
return array(
- array('Foreach: {foreach} {$e}, {/foreach} end', 'Cytro\CompileException', "Unexpected end of tag {foreach}"),
- array('Foreach: {foreach $list} {$e}, {/foreach} end', 'Cytro\CompileException', "Unexpected end of expression"),
- array('Foreach: {foreach $list+1 as $e} {$e}, {/foreach} end', 'Cytro\CompileException', "Unexpected token '+'"),
- array('Foreach: {foreach array_random() as $e} {$e}, {/foreach} end', 'Cytro\CompileException', "Unexpected token 'array_random'"),
- array('Foreach: {foreach $list as $e+1} {$e}, {/foreach} end', 'Cytro\CompileException', "Unexpected token '+'"),
- array('Foreach: {foreach $list as $k+1 => $e} {$e}, {/foreach} end', 'Cytro\CompileException', "Unexpected token '+'"),
- array('Foreach: {foreach $list as max($i,1) => $e} {$e}, {/foreach} end', 'Cytro\CompileException', "Unexpected token 'max'"),
- array('Foreach: {foreach $list as max($e,1)} {$e}, {/foreach} end', 'Cytro\CompileException', "Unexpected token 'max'"),
- array('Foreach: {foreach $list => $e} {$e}, {/foreach} end', 'Cytro\CompileException', "Unexpected token '=>'"),
- array('Foreach: {foreach $list $k => $e} {$e}, {/foreach} end', 'Cytro\CompileException', "Unexpected token '\$k'"),
- array('Foreach: {foreach $list as $k =>} {$e}, {/foreach} end', 'Cytro\CompileException', "Unexpected end of expression"),
- array('Foreach: {foreach last=$l $list as $e } {$e}, {/foreach} end', 'Cytro\CompileException', "Unexpected token 'last' in tag {foreach}"),
- array('Foreach: {foreach $list as $e unknown=1} {$e}, {/foreach} end', 'Cytro\CompileException', "Unknown parameter 'unknown'"),
- array('Foreach: {foreach $list as $e index=$i+1} {$e}, {/foreach} end', 'Cytro\CompileException', "Unexpected token '+'"),
- array('Foreach: {foreach $list as $e first=$f+1} {$e}, {/foreach} end', 'Cytro\CompileException', "Unexpected token '+'"),
- array('Foreach: {foreach $list as $e last=$l+1} {$e}, {/foreach} end', 'Cytro\CompileException', "Unexpected token '+'"),
- array('Foreach: {foreach $list as $e index=max($i,1)} {$e}, {/foreach} end', 'Cytro\CompileException', "Unexpected token 'max'"),
- array('Foreach: {foreach $list as $e first=max($i,1)} {$e}, {/foreach} end', 'Cytro\CompileException', "Unexpected token 'max'"),
- array('Foreach: {foreach $list as $e last=max($i,1)} {$e}, {/foreach} end', 'Cytro\CompileException', "Unexpected token 'max'"),
- array('Foreach: {foreach $list as $e} {$e}, {foreachelse} {break} {/foreach} end', 'Cytro\CompileException', "Improper usage of the tag {break}"),
- array('Foreach: {foreach $list as $e} {$e}, {foreachelse} {continue} {/foreach} end', 'Cytro\CompileException', "Improper usage of the tag {continue}"),
+ array('Foreach: {foreach} {$e}, {/foreach} end', 'Fenom\CompileException', "Unexpected end of tag {foreach}"),
+ array('Foreach: {foreach $list} {$e}, {/foreach} end', 'Fenom\CompileException', "Unexpected end of expression"),
+ array('Foreach: {foreach $list+1 as $e} {$e}, {/foreach} end', 'Fenom\CompileException', "Unexpected token '+'"),
+ array('Foreach: {foreach array_random() as $e} {$e}, {/foreach} end', 'Fenom\CompileException', "Unexpected token 'array_random'"),
+ array('Foreach: {foreach $list as $e+1} {$e}, {/foreach} end', 'Fenom\CompileException', "Unexpected token '+'"),
+ array('Foreach: {foreach $list as $k+1 => $e} {$e}, {/foreach} end', 'Fenom\CompileException', "Unexpected token '+'"),
+ array('Foreach: {foreach $list as max($i,1) => $e} {$e}, {/foreach} end', 'Fenom\CompileException', "Unexpected token 'max'"),
+ array('Foreach: {foreach $list as max($e,1)} {$e}, {/foreach} end', 'Fenom\CompileException', "Unexpected token 'max'"),
+ array('Foreach: {foreach $list => $e} {$e}, {/foreach} end', 'Fenom\CompileException', "Unexpected token '=>'"),
+ array('Foreach: {foreach $list $k => $e} {$e}, {/foreach} end', 'Fenom\CompileException', "Unexpected token '\$k'"),
+ array('Foreach: {foreach $list as $k =>} {$e}, {/foreach} end', 'Fenom\CompileException', "Unexpected end of expression"),
+ array('Foreach: {foreach last=$l $list as $e } {$e}, {/foreach} end', 'Fenom\CompileException', "Unexpected token 'last' in tag {foreach}"),
+ array('Foreach: {foreach $list as $e unknown=1} {$e}, {/foreach} end', 'Fenom\CompileException', "Unknown parameter 'unknown'"),
+ array('Foreach: {foreach $list as $e index=$i+1} {$e}, {/foreach} end', 'Fenom\CompileException', "Unexpected token '+'"),
+ array('Foreach: {foreach $list as $e first=$f+1} {$e}, {/foreach} end', 'Fenom\CompileException', "Unexpected token '+'"),
+ array('Foreach: {foreach $list as $e last=$l+1} {$e}, {/foreach} end', 'Fenom\CompileException', "Unexpected token '+'"),
+ array('Foreach: {foreach $list as $e index=max($i,1)} {$e}, {/foreach} end', 'Fenom\CompileException', "Unexpected token 'max'"),
+ array('Foreach: {foreach $list as $e first=max($i,1)} {$e}, {/foreach} end', 'Fenom\CompileException', "Unexpected token 'max'"),
+ array('Foreach: {foreach $list as $e last=max($i,1)} {$e}, {/foreach} end', 'Fenom\CompileException', "Unexpected token 'max'"),
+ array('Foreach: {foreach $list as $e} {$e}, {foreachelse} {break} {/foreach} end', 'Fenom\CompileException', "Improper usage of the tag {break}"),
+ array('Foreach: {foreach $list as $e} {$e}, {foreachelse} {continue} {/foreach} end', 'Fenom\CompileException', "Improper usage of the tag {continue}"),
);
}
@@ -483,9 +483,9 @@ class TemplateTest extends TestCase {
public static function providerSwitchInvalid() {
return array(
- array('Switch: {switch}{case 1} one {break}{/switch} end', 'Cytro\CompileException', "Unexpected end of expression"),
- array('Switch: {switch 1}{case} one {break}{/switch} end', 'Cytro\CompileException', "Unexpected end of expression"),
- array('Switch: {switch 1}{break}{case} one {/switch} end', 'Cytro\CompileException', "Improper usage of the tag {break}"),
+ array('Switch: {switch}{case 1} one {break}{/switch} end', 'Fenom\CompileException', "Unexpected end of expression"),
+ array('Switch: {switch 1}{case} one {break}{/switch} end', 'Fenom\CompileException', "Unexpected end of expression"),
+ array('Switch: {switch 1}{break}{case} one {/switch} end', 'Fenom\CompileException', "Improper usage of the tag {break}"),
);
}
@@ -501,7 +501,7 @@ class TemplateTest extends TestCase {
public static function providerWhileInvalid() {
return array(
- array('While: {while} block {/while} end', 'Cytro\CompileException', "Unexpected end of expression"),
+ array('While: {while} block {/while} end', 'Fenom\CompileException', "Unexpected end of expression"),
);
}
@@ -529,29 +529,29 @@ class TemplateTest extends TestCase {
public static function providerForInvalid() {
return array(
- array('For: {for} block1 {/for} end', 'Cytro\CompileException', "Unexpected end of expression"),
- array('For: {for $a=} block1 {/for} end', 'Cytro\CompileException', "Unexpected end of expression"),
- array('For: {for $a+1=3 to=6} block1 {/for} end', 'Cytro\CompileException', "Unexpected token '+'"),
- array('For: {for max($a,$b)=3 to=6} block1 {/for} end', 'Cytro\CompileException', "Unexpected token 'max'"),
- array('For: {for to=6 $a=3} block1 {/for} end', 'Cytro\CompileException', "Unexpected token 'to'"),
- array('For: {for index=$i $a=3 to=6} block1 {/for} end', 'Cytro\CompileException', "Unexpected token 'index'"),
- array('For: {for first=$i $a=3 to=6} block1 {/for} end', 'Cytro\CompileException', "Unexpected token 'first'"),
- array('For: {for last=$i $a=3 to=6} block1 {/for} end', 'Cytro\CompileException', "Unexpected token 'last'"),
- array('For: {for $a=4 to=6 unk=4} block1 {/for} end', 'Cytro\CompileException', "Unknown parameter 'unk'"),
- array('For: {for $a=4 to=6} $a: {$a}, {forelse} {break} {/for} end', 'Cytro\CompileException', "Improper usage of the tag {break}"),
- array('For: {for $a=4 to=6} $a: {$a}, {forelse} {continue} {/for} end', 'Cytro\CompileException', "Improper usage of the tag {continue}"),
+ array('For: {for} block1 {/for} end', 'Fenom\CompileException', "Unexpected end of expression"),
+ array('For: {for $a=} block1 {/for} end', 'Fenom\CompileException', "Unexpected end of expression"),
+ array('For: {for $a+1=3 to=6} block1 {/for} end', 'Fenom\CompileException', "Unexpected token '+'"),
+ array('For: {for max($a,$b)=3 to=6} block1 {/for} end', 'Fenom\CompileException', "Unexpected token 'max'"),
+ array('For: {for to=6 $a=3} block1 {/for} end', 'Fenom\CompileException', "Unexpected token 'to'"),
+ array('For: {for index=$i $a=3 to=6} block1 {/for} end', 'Fenom\CompileException', "Unexpected token 'index'"),
+ array('For: {for first=$i $a=3 to=6} block1 {/for} end', 'Fenom\CompileException', "Unexpected token 'first'"),
+ array('For: {for last=$i $a=3 to=6} block1 {/for} end', 'Fenom\CompileException', "Unexpected token 'last'"),
+ array('For: {for $a=4 to=6 unk=4} block1 {/for} end', 'Fenom\CompileException', "Unknown parameter 'unk'"),
+ array('For: {for $a=4 to=6} $a: {$a}, {forelse} {break} {/for} end', 'Fenom\CompileException', "Improper usage of the tag {break}"),
+ array('For: {for $a=4 to=6} $a: {$a}, {forelse} {continue} {/for} end', 'Fenom\CompileException', "Improper usage of the tag {continue}"),
);
}
public static function providerLayersInvalid() {
return array(
- array('Layers: {foreach $list as $e} block1 {if 1} {foreachelse} {/if} {/foreach} end', 'Cytro\CompileException', "Unexpected tag 'foreachelse' (this tag can be used with 'foreach')"),
- array('Layers: {foreach $list as $e} block1 {if 1} {/foreach} {/if} end', 'Cytro\CompileException', "Unexpected closing of the tag 'foreach'"),
- array('Layers: {for $a=4 to=6} block1 {if 1} {forelse} {/if} {/for} end', 'Cytro\CompileException', "Unexpected tag 'forelse' (this tag can be used with 'for')"),
- array('Layers: {for $a=4 to=6} block1 {if 1} {/for} {/if} end', 'Cytro\CompileException', "Unexpected closing of the tag 'for'"),
- array('Layers: {switch 1} {if 1} {case 1} {/if} {/switch} end', 'Cytro\CompileException', "Unexpected tag 'case' (this tag can be used with 'switch')"),
- array('Layers: {/switch} end', 'Cytro\CompileException', "Unexpected closing of the tag 'switch'"),
- array('Layers: {if 1} end', 'Cytro\CompileException', "Unclosed tag: {if}"),
+ array('Layers: {foreach $list as $e} block1 {if 1} {foreachelse} {/if} {/foreach} end', 'Fenom\CompileException', "Unexpected tag 'foreachelse' (this tag can be used with 'foreach')"),
+ array('Layers: {foreach $list as $e} block1 {if 1} {/foreach} {/if} end', 'Fenom\CompileException', "Unexpected closing of the tag 'foreach'"),
+ array('Layers: {for $a=4 to=6} block1 {if 1} {forelse} {/if} {/for} end', 'Fenom\CompileException', "Unexpected tag 'forelse' (this tag can be used with 'for')"),
+ array('Layers: {for $a=4 to=6} block1 {if 1} {/for} {/if} end', 'Fenom\CompileException', "Unexpected closing of the tag 'for'"),
+ array('Layers: {switch 1} {if 1} {case 1} {/if} {/switch} end', 'Fenom\CompileException', "Unexpected tag 'case' (this tag can be used with 'switch')"),
+ array('Layers: {/switch} end', 'Fenom\CompileException', "Unexpected closing of the tag 'switch'"),
+ array('Layers: {if 1} end', 'Fenom\CompileException', "Unclosed tag: {if}"),
);
}
diff --git a/tests/cases/Cytro/TokenizerTest.php b/tests/cases/Fenom/TokenizerTest.php
similarity index 95%
rename from tests/cases/Cytro/TokenizerTest.php
rename to tests/cases/Fenom/TokenizerTest.php
index 95ef149..99b2946 100644
--- a/tests/cases/Cytro/TokenizerTest.php
+++ b/tests/cases/Fenom/TokenizerTest.php
@@ -1,6 +1,6 @@
skip(T_STRING)->skip('(')->skip(':');
} catch(\Exception $e) {
- $this->assertInstanceOf('Cytro\UnexpectedTokenException', $e);
+ $this->assertInstanceOf('Fenom\UnexpectedTokenException', $e);
$this->assertStringStartsWith("Unexpected token '3' in expression, expect ':'", $e->getMessage());
}
$this->assertTrue($tokens->valid());
diff --git a/tests/resources/actions.php b/tests/resources/actions.php
index e22887f..5ae3f7d 100644
--- a/tests/resources/actions.php
+++ b/tests/resources/actions.php
@@ -12,20 +12,20 @@ function myBlockFunc($params, $content) {
return "Block:".$params["name"].':'.trim($content).':Block';
}
-function myCompiler(Cytro\Tokenizer $tokenizer, Cytro\Template $tpl) {
+function myCompiler(Fenom\Tokenizer $tokenizer, Fenom\Template $tpl) {
$p = $tpl->parseParams($tokenizer);
return 'echo "PHP_VERSION: ".PHP_VERSION." (for ".'.$p["name"].'.")";';
}
-function myBlockCompilerOpen(Cytro\Tokenizer $tokenizer, Cytro\Scope $scope) {
+function myBlockCompilerOpen(Fenom\Tokenizer $tokenizer, Fenom\Scope $scope) {
return myCompiler($tokenizer, $scope->tpl);
}
-function myBlockCompilerClose(Cytro\Tokenizer $tokenizer, Cytro\Scope $scope) {
+function myBlockCompilerClose(Fenom\Tokenizer $tokenizer, Fenom\Scope $scope) {
return 'echo "End of compiler";';
}
-function myBlockCompilerTag(Cytro\Tokenizer $tokenizer, Cytro\Scope $scope) {
+function myBlockCompilerTag(Fenom\Tokenizer $tokenizer, Fenom\Scope $scope) {
$p = $scope->tpl->parseParams($tokenizer);
return 'echo "Tag ".'.$p["name"].'." of compiler";';
}
\ No newline at end of file