diff --git a/CHANGELOG.md b/CHANGELOG.md index 4893020..1a13a23 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,14 @@ Changelog ========= -## 2.0.0RC1 +## 2.0.1 + +- Fix string concatenation. If `~` in the end of expression Fenom generates broken template. +- Fix `~=` operator. Operator was not working. +- Tests++ +- Docs++ + +## 2.0.0 - Add tag the {filter} - Redesign `extends` algorithm: diff --git a/docs/helpme.md b/docs/helpme.md new file mode 100644 index 0000000..c553994 --- /dev/null +++ b/docs/helpme.md @@ -0,0 +1,9 @@ +Требуется помощь в переводе документации +======================================== + +Принимаю любую помощь в переводе статей документации. Вносить правки в документацию можете любым удобным: + +* Сделать merge request (нажав `Edit` ввержу файла) +* Прислать адресс статьи и что на что заменить. В письме лучше укажите `Fenom docs`. + +Заранее благодарен! \ No newline at end of file diff --git a/docs/tags/ignore.md b/docs/tags/ignore.md index d6ec197..f80860d 100644 --- a/docs/tags/ignore.md +++ b/docs/tags/ignore.md @@ -1,7 +1,9 @@ -Tag {ignore} [RU] -================= +Tag {ignore} +============ -Тег {ignore} позволяет отключить парсер на фрагмент шаблона, таким образом все фигурные скобки в блоке будут проигнорированы. +{ignore} tags allow a block of data to be taken literally. +This is typically used around Javascript or stylesheet blocks where {curly braces} would interfere with the template delimiter syntax. +Anything within {ignore}{/ignore} tags is not interpreted, but displayed as-is. ```smarty {ignore} @@ -9,7 +11,9 @@ Tag {ignore} [RU] {/ignore} ``` -You may ignore delimiters without tag `{ignore}` +{ignore} tags are normally not necessary, as Fenom ignores delimiters that are surrounded by whitespace. +Be sure your javascript and CSS curly braces are surrounded by whitespace: + ```smarty var data = { "time": obj.ts }; ``` \ No newline at end of file diff --git a/docs/tags/include.md b/docs/tags/include.md index 2c7d678..50a68d7 100644 --- a/docs/tags/include.md +++ b/docs/tags/include.md @@ -1,5 +1,5 @@ -Tag {include} [RU] -================== +Tag {include} +============= `{include}` tags are used for including other templates in the current template. Any variables available in the current template are also available within the included template. @@ -7,20 +7,21 @@ Tag {include} [RU] {include "about.tpl"} ``` -Переменные для подключаемого шаблона можно переопределить, задавая их аргументами тега. +If you need to set yours variables for template list them in attributes. ```smarty {include "about.tpl" page=$item limit=50} ``` -Все изменения переменных в подключаемом шаблоне не будут воздействовать на родительский шаблон. +All variables changed in child template has no affect to variables in parent template. ### {insert} The tag insert template code instead self. -* No dynamic name allowed -* No variables as attribute allowed +* No dynamic name allowed. +* No variables as attribute allowed. +* Increase performance because insert code as is in compilation time. For example, main.tpl: @@ -36,7 +37,7 @@ b.tpl: b: {$b} ``` -Во время разбора шаблона код шаблона `b.tpl` будет вставлен в код шаблона `main.tpl` как есть: +Code of `b.tpl` will be inserted into `main.tpl` as is: ```smarty a: {$a} diff --git a/sandbox/fenom.php b/sandbox/fenom.php index 26843eb..e76845b 100644 --- a/sandbox/fenom.php +++ b/sandbox/fenom.php @@ -15,11 +15,5 @@ namespace { $fenom = Fenom::factory(__DIR__.'/templates', __DIR__.'/compiled', Fenom::FORCE_COMPILE); - $fenom->display("extends/75-child.tpl", array( - "user" => array( - "name" => "Ivka", - 'type' => 'new' - ), - 'type' => 'new' - )); + var_dump($fenom->compile("concat-bug.tpl", false)->getBody()); } \ No newline at end of file diff --git a/sandbox/templates/concat-bug.tpl b/sandbox/templates/concat-bug.tpl new file mode 100644 index 0000000..4f9fa48 --- /dev/null +++ b/sandbox/templates/concat-bug.tpl @@ -0,0 +1,2 @@ +Some eval: +{$dop_content = ": some texta"} \ No newline at end of file diff --git a/src/Fenom/Template.php b/src/Fenom/Template.php index 1682522..edff568 100644 --- a/src/Fenom/Template.php +++ b/src/Fenom/Template.php @@ -379,6 +379,9 @@ class Template extends Render } } + /** + * @param $tag_name + */ public function ignore($tag_name) { $this->_ignore = $tag_name; } @@ -729,12 +732,15 @@ class Template extends Render $tokens->next()->next(); } else { $concat = array(array_pop($exp)); + while ($tokens->is('~')) { $tokens->next(); if ($tokens->is(T_LNUMBER, T_DNUMBER)) { $concat[] = "strval(" . $this->parseTerm($tokens) . ")"; } else { - $concat[] = $this->parseTerm($tokens); + if(!$concat[] = $this->parseTerm($tokens)) { + throw new UnexpectedTokenException($tokens); + } } } $exp[] = "(" . implode(".", $concat) . ")";