mirror of
https://github.com/fenom-template/fenom.git
synced 2023-08-10 21:13:07 +03:00
Merge branch 'origin/master'
This commit is contained in:
commit
24f22f8f43
19
CHANGELOG.md
19
CHANGELOG.md
|
@ -1,12 +1,27 @@
|
||||||
Changelog
|
Changelog
|
||||||
=========
|
=========
|
||||||
|
|
||||||
### 1.4.4
|
### 1.4.7 (2013-09-19)
|
||||||
|
|
||||||
- Bug fixes
|
- Bug fixes
|
||||||
- Tests++
|
- Tests++
|
||||||
|
|
||||||
### 1.4.3
|
### 1.4.6 (2013-09-19)
|
||||||
|
|
||||||
|
- Bug fixes
|
||||||
|
- Tests++
|
||||||
|
|
||||||
|
### 1.4.5 (2013-09-15)
|
||||||
|
|
||||||
|
- Bug fixes
|
||||||
|
- Tests++
|
||||||
|
|
||||||
|
### 1.4.4 (2013-09-13)
|
||||||
|
|
||||||
|
- Bug fixes
|
||||||
|
- Tests++
|
||||||
|
|
||||||
|
### 1.4.3 (2013-09-10)
|
||||||
|
|
||||||
- Bug fixes
|
- Bug fixes
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
Fenom - Template Engine for PHP
|
Fenom - Template Engine for PHP
|
||||||
===============================
|
===============================
|
||||||
|
|
||||||
> Composer package: `{"fenom/fenom": "dev-master"}`. See on [Packagist.org](https://packagist.org/packages/fenom/fenom)
|
> Composer package: `{"fenom/fenom": "1.*"}`. See on [Packagist.org](https://packagist.org/packages/fenom/fenom)
|
||||||
|
|
||||||
[![Latest Stable Version](https://poser.pugx.org/fenom/fenom/v/stable.png)](https://packagist.org/packages/fenom/fenom)
|
[![Latest Stable Version](https://poser.pugx.org/fenom/fenom/v/stable.png)](https://packagist.org/packages/fenom/fenom)
|
||||||
[![Build Status](https://travis-ci.org/bzick/fenom.png?branch=master)](https://travis-ci.org/bzick/fenom)
|
[![Build Status](https://travis-ci.org/bzick/fenom.png?branch=master)](https://travis-ci.org/bzick/fenom)
|
||||||
[![Coverage Status](https://coveralls.io/repos/bzick/fenom/badge.png?branch=master)](https://coveralls.io/r/bzick/fenom?branch=master)
|
[![Coverage Status](https://coveralls.io/repos/bzick/fenom/badge.png?branch=master)](https://coveralls.io/r/bzick/fenom?branch=master)
|
||||||
|
[![Total Downloads](https://poser.pugx.org/fenom/fenom/downloads.png)](https://packagist.org/packages/fenom/fenom)
|
||||||
## [Usage](./docs/usage.md) :: [Documentation](./docs/readme.md) :: [Benchmark](./docs/benchmark.md) :: [Articles](./docs/articles.md)
|
## [Usage](./docs/usage.md) :: [Documentation](./docs/readme.md) :: [Benchmark](./docs/benchmark.md) :: [Articles](./docs/articles.md)
|
||||||
|
|
||||||
* Simple [syntax](./docs/syntax.md)
|
* Simple [syntax](./docs/syntax.md)
|
||||||
|
|
|
@ -5,7 +5,7 @@ For installation use [composer](http://getcomposer.org). Add in your `composer.j
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"require": {
|
"require": {
|
||||||
"fenom/fenom": "dev-master"
|
"fenom/fenom": "1.*"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
Settings [RU]
|
Settings
|
||||||
=============
|
========
|
||||||
|
|
||||||
### Engine settings
|
### Template cache
|
||||||
|
|
||||||
Что бы установить папку для хранения кеша собранных шаблонов
|
|
||||||
|
|
||||||
```php
|
```php
|
||||||
$fenom->setCompileDir($dir);
|
$fenom->setCompileDir($dir);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
This method set the name of the directory where template caches are stored. By default this is `/tmp`. This directory must be writeable.
|
||||||
|
|
||||||
### Template settings
|
### Template settings
|
||||||
|
|
||||||
```php
|
```php
|
||||||
|
@ -20,7 +20,7 @@ $fenom->setOptions($options);
|
||||||
|
|
||||||
Параметры могут быть массивом `'option_name' => true` (если ключ не указан автоматически задаётся false) или битовой маской.
|
Параметры могут быть массивом `'option_name' => true` (если ключ не указан автоматически задаётся false) или битовой маской.
|
||||||
|
|
||||||
* **disable_methods**, `Fenom::DENY_METHODS`, запретить вызов методов у объектов
|
* **disable_methods**, `Fenom::DENY_METHODS`, disable calling methods in templates. Any method call in the template will throw `Fenom\SecurityException`.
|
||||||
* **disable_native_funcs**, `Fenom::DENY_INLINE_FUNCS`, запретить использование PHP функций, кроме разрешенных.
|
* **disable_native_funcs**, `Fenom::DENY_INLINE_FUNCS`, запретить использование PHP функций, кроме разрешенных.
|
||||||
* **auto_reload**, `Fenom::AUTO_RELOAD`, пересобирать шаблон если его оригинал был изменён (замедляет работу шаблонизатора).
|
* **auto_reload**, `Fenom::AUTO_RELOAD`, пересобирать шаблон если его оригинал был изменён (замедляет работу шаблонизатора).
|
||||||
* **force_compile**, `Fenom::FORCE_COMPILE`, пересобирать шаблон при каждом вызове (сильно замедляет работу шаблонизатора).
|
* **force_compile**, `Fenom::FORCE_COMPILE`, пересобирать шаблон при каждом вызове (сильно замедляет работу шаблонизатора).
|
||||||
|
|
|
@ -570,12 +570,12 @@ class Compiler
|
||||||
$tpl->addDepend($donor);
|
$tpl->addDepend($donor);
|
||||||
return '?>' . $donor->getBody() . '<?php ';
|
return '?>' . $donor->getBody() . '<?php ';
|
||||||
} else {
|
} else {
|
||||||
// throw new InvalidUsageException('template name must be given explicitly yet');
|
throw new InvalidUsageException('template name must be given explicitly yet');
|
||||||
// under construction
|
// under construction
|
||||||
$tpl->_compatible = true;
|
// $tpl->_compatible = true;
|
||||||
return '$donor = $tpl->getStorage()->getTemplate(' . $cname . ', \Fenom\Template::EXTENDED);' . PHP_EOL .
|
// return '$donor = $tpl->getStorage()->getTemplate(' . $cname . ', \Fenom\Template::EXTENDED);' . PHP_EOL .
|
||||||
'$donor->fetch((array)$tpl);' . PHP_EOL .
|
// '$donor->fetch((array)$tpl);' . PHP_EOL .
|
||||||
'$tpl->b += (array)$donor->b';
|
// '$tpl->b += (array)$donor->b';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1000,10 +1000,10 @@ class Compiler
|
||||||
$tag = $tpl->getStorage()->getTag($func, $tpl);
|
$tag = $tpl->getStorage()->getTag($func, $tpl);
|
||||||
if ($tag["type"] == \Fenom::INLINE_FUNCTION) {
|
if ($tag["type"] == \Fenom::INLINE_FUNCTION) {
|
||||||
$code = $tpl->parseAct($tokens);
|
$code = $tpl->parseAct($tokens);
|
||||||
} elseif ($tag["type"] == \Fenom::BLOCK_FUNCTION) {
|
// } elseif ($tag["type"] == \Fenom::BLOCK_FUNCTION) {
|
||||||
$code = $tpl->parseAct($tokens);
|
// $code = $tpl->parseAct($tokens);
|
||||||
$tpl->getLastScope()->escape = false;
|
// $tpl->getLastScope()->escape = false;
|
||||||
return $code;
|
// return $code;
|
||||||
} else {
|
} else {
|
||||||
throw new InvalidUsageException("Raw mode allow for expressions or functions");
|
throw new InvalidUsageException("Raw mode allow for expressions or functions");
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,7 @@ class Tokenizer
|
||||||
* @see http://docs.php.net/manual/en/tokens.php
|
* @see http://docs.php.net/manual/en/tokens.php
|
||||||
* @var array groups of tokens
|
* @var array groups of tokens
|
||||||
*/
|
*/
|
||||||
private static $_macros = array(
|
public static $macros = array(
|
||||||
self::MACRO_STRING => array(
|
self::MACRO_STRING => array(
|
||||||
\T_ABSTRACT => 1, \T_ARRAY => 1, \T_AS => 1, \T_BREAK => 1, \T_BREAK => 1, \T_CASE => 1,
|
\T_ABSTRACT => 1, \T_ARRAY => 1, \T_AS => 1, \T_BREAK => 1, \T_BREAK => 1, \T_CASE => 1,
|
||||||
\T_CATCH => 1, \T_CLASS => 1, \T_CLASS_C => 1, \T_CLONE => 1, \T_CONST => 1, \T_CONTINUE => 1,
|
\T_CATCH => 1, \T_CLASS => 1, \T_CLASS_C => 1, \T_CLONE => 1, \T_CONST => 1, \T_CONTINUE => 1,
|
||||||
|
@ -255,7 +255,7 @@ class Tokenizer
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (isset(self::$_macros[$expect][$token])) {
|
if (isset(self::$macros[$expect][$token])) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,5 +102,17 @@ class ProviderTest extends TestCase
|
||||||
"template2.tpl"
|
"template2.tpl"
|
||||||
), $list);
|
), $list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testRm() {
|
||||||
|
$this->assertTrue(is_dir(FENOM_RESOURCES . '/template/sub'));
|
||||||
|
Provider::rm(FENOM_RESOURCES . '/template/sub');
|
||||||
|
$this->assertFalse(is_dir(FENOM_RESOURCES . '/template/sub'));
|
||||||
|
$this->assertTrue(is_file(FENOM_RESOURCES . '/template/template1.tpl'));
|
||||||
|
Provider::rm(FENOM_RESOURCES . '/template/template1.tpl');
|
||||||
|
$this->assertFalse(is_file(FENOM_RESOURCES . '/template/template1.tpl'));
|
||||||
|
$this->assertTrue(is_file(FENOM_RESOURCES . '/template/template2.tpl'));
|
||||||
|
Provider::clean(FENOM_RESOURCES . '/template/');
|
||||||
|
$this->assertFalse(is_file(FENOM_RESOURCES . '/template/template2.tpl'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -770,7 +770,7 @@ class TemplateTest extends TestCase
|
||||||
public function _testSandbox()
|
public function _testSandbox()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
var_dump($this->fenom->setOptions(Fenom::FORCE_VERIFY)->addFilter(function ($txt) {return $txt;})->compileCode('- <?php {$a} ?> -')->fetch(['a' => 1]));
|
var_dump($this->fenom->setOptions(Fenom::FORCE_VERIFY)->addFilter(function ($txt) {return $txt;})->compileCode('- {$a} -')->fetch(array('a' => 1)));
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
print_r($e->getMessage() . "\n" . $e->getTraceAsString());
|
print_r($e->getMessage() . "\n" . $e->getTraceAsString());
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ class TokenizerTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
$code = 'hello, please resolve this example: sin($x)+tan($x*$t) = {U|[0,1]}';
|
$code = 'hello, please resolve this example: sin($x)+tan($x*$t) = {U|[0,1]}';
|
||||||
$tokens = new Tokenizer($code);
|
$tokens = new Tokenizer($code);
|
||||||
|
$this->assertSame(27, $tokens->count());
|
||||||
$this->assertSame($tokens, $tokens->back());
|
$this->assertSame($tokens, $tokens->back());
|
||||||
$this->assertSame(T_STRING, $tokens->key());
|
$this->assertSame(T_STRING, $tokens->key());
|
||||||
$this->assertSame("hello", $tokens->current());
|
$this->assertSame("hello", $tokens->current());
|
||||||
|
@ -55,6 +56,8 @@ class TokenizerTest extends \PHPUnit_Framework_TestCase
|
||||||
$this->assertFalse($tokens->is(T_DNUMBER));
|
$this->assertFalse($tokens->is(T_DNUMBER));
|
||||||
$this->assertFalse($tokens->is(":"));
|
$this->assertFalse($tokens->is(":"));
|
||||||
$this->assertSame("(", $tokens->getNext("(", ")"));
|
$this->assertSame("(", $tokens->getNext("(", ")"));
|
||||||
|
$this->assertTrue($tokens->hasBackList(T_STRING, ':'));
|
||||||
|
$this->assertFalse($tokens->hasBackList(T_LNUMBER, ':'));
|
||||||
|
|
||||||
$tokens->next();
|
$tokens->next();
|
||||||
$tokens->next();
|
$tokens->next();
|
||||||
|
@ -87,6 +90,11 @@ class TokenizerTest extends \PHPUnit_Framework_TestCase
|
||||||
$this->assertSame(")", $tokens->current());
|
$this->assertSame(")", $tokens->current());
|
||||||
$this->assertTrue($tokens->isLast());
|
$this->assertTrue($tokens->isLast());
|
||||||
$this->assertSame($tokens, $tokens->next());
|
$this->assertSame($tokens, $tokens->next());
|
||||||
|
$tokens->p = 1000;
|
||||||
|
$this->assertSame($tokens, $tokens->next());
|
||||||
|
$tokens->p = -1000;
|
||||||
|
$this->assertSame($tokens, $tokens->back());
|
||||||
|
$this->assertNull($tokens->undef);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user