This commit is contained in:
bzick 2014-06-09 23:40:31 +04:00
parent f3de50813e
commit ad9a601b9f
7 changed files with 43 additions and 20 deletions

View File

@ -1,7 +1,14 @@
Changelog 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} - Add tag the {filter}
- Redesign `extends` algorithm: - Redesign `extends` algorithm:

9
docs/helpme.md Normal file
View File

@ -0,0 +1,9 @@
Требуется помощь в переводе документации
========================================
Принимаю любую помощь в переводе статей документации. Вносить правки в документацию можете любым удобным:
* Сделать merge request (нажав `Edit` ввержу файла)
* Прислать адресс статьи и что на что заменить. В письме лучше укажите `Fenom docs`.
Заранее благодарен!

View File

@ -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 ```smarty
{ignore} {ignore}
@ -9,7 +11,9 @@ Tag {ignore} [RU]
{/ignore} {/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 ```smarty
var data = { "time": obj.ts }; var data = { "time": obj.ts };
``` ```

View File

@ -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. `{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"} {include "about.tpl"}
``` ```
Переменные для подключаемого шаблона можно переопределить, задавая их аргументами тега. If you need to set yours variables for template list them in attributes.
```smarty ```smarty
{include "about.tpl" page=$item limit=50} {include "about.tpl" page=$item limit=50}
``` ```
Все изменения переменных в подключаемом шаблоне не будут воздействовать на родительский шаблон. All variables changed in child template has no affect to variables in parent template.
### {insert} ### {insert}
The tag insert template code instead self. The tag insert template code instead self.
* No dynamic name allowed * No dynamic name allowed.
* No variables as attribute allowed * No variables as attribute allowed.
* Increase performance because insert code as is in compilation time.
For example, main.tpl: For example, main.tpl:
@ -36,7 +37,7 @@ b.tpl:
b: {$b} b: {$b}
``` ```
Во время разбора шаблона код шаблона `b.tpl` будет вставлен в код шаблона `main.tpl` как есть: Code of `b.tpl` will be inserted into `main.tpl` as is:
```smarty ```smarty
a: {$a} a: {$a}

View File

@ -15,11 +15,5 @@ namespace {
$fenom = Fenom::factory(__DIR__.'/templates', __DIR__.'/compiled', Fenom::FORCE_COMPILE); $fenom = Fenom::factory(__DIR__.'/templates', __DIR__.'/compiled', Fenom::FORCE_COMPILE);
$fenom->display("extends/75-child.tpl", array( var_dump($fenom->compile("concat-bug.tpl", false)->getBody());
"user" => array(
"name" => "Ivka",
'type' => 'new'
),
'type' => 'new'
));
} }

View File

@ -0,0 +1,2 @@
Some eval:
{$dop_content = ": some texta"}

View File

@ -379,6 +379,9 @@ class Template extends Render
} }
} }
/**
* @param $tag_name
*/
public function ignore($tag_name) { public function ignore($tag_name) {
$this->_ignore = $tag_name; $this->_ignore = $tag_name;
} }
@ -729,12 +732,15 @@ class Template extends Render
$tokens->next()->next(); $tokens->next()->next();
} else { } else {
$concat = array(array_pop($exp)); $concat = array(array_pop($exp));
while ($tokens->is('~')) { while ($tokens->is('~')) {
$tokens->next(); $tokens->next();
if ($tokens->is(T_LNUMBER, T_DNUMBER)) { if ($tokens->is(T_LNUMBER, T_DNUMBER)) {
$concat[] = "strval(" . $this->parseTerm($tokens) . ")"; $concat[] = "strval(" . $this->parseTerm($tokens) . ")";
} else { } else {
$concat[] = $this->parseTerm($tokens); if(!$concat[] = $this->parseTerm($tokens)) {
throw new UnexpectedTokenException($tokens);
}
} }
} }
$exp[] = "(" . implode(".", $concat) . ")"; $exp[] = "(" . implode(".", $concat) . ")";