mirror of
https://github.com/fenom-template/fenom.git
synced 2023-08-10 21:13:07 +03:00
Update var.md
This commit is contained in:
parent
8a249b4850
commit
a7a25cd622
@ -1,7 +1,7 @@
|
|||||||
Tag {var} [RU]
|
Tag {var}
|
||||||
==============
|
=========
|
||||||
|
|
||||||
Тег {var} предназначен для создания переменных в шаблонах.
|
The tag {var} is used for assigning template variables during the execution of a template.
|
||||||
|
|
||||||
```smarty
|
```smarty
|
||||||
{var $var=EXPR}
|
{var $var=EXPR}
|
||||||
@ -19,8 +19,8 @@ Tag {var} [RU]
|
|||||||
{/var}
|
{/var}
|
||||||
```
|
```
|
||||||
|
|
||||||
К названию новой переменной предъявляются те же требования, что и к [именам переменных](http://www.php.net/manual/en/language.variables.basics.php) в PHP.
|
Variable names follow the same rules as other labels in PHP.
|
||||||
Выражение EXPR подразумевает любое поддерживаемое выражение.
|
A valid variable name starts with a letter or underscore, followed by any number of letters, numbers, or underscores.
|
||||||
|
|
||||||
```smarty
|
```smarty
|
||||||
{var $v = 5}
|
{var $v = 5}
|
||||||
@ -34,18 +34,26 @@ Tag {var} [RU]
|
|||||||
{var $v = $y-$x}
|
{var $v = $y-$x}
|
||||||
{var $v = $y*$x-2}
|
{var $v = $y*$x-2}
|
||||||
{var $v = ($y^$x)+7}
|
{var $v = ($y^$x)+7}
|
||||||
|
```
|
||||||
|
|
||||||
Присваивание массивов
|
Creating array
|
||||||
|
|
||||||
|
```smarty
|
||||||
{var $v = [1,2,3]}
|
{var $v = [1,2,3]}
|
||||||
{var $v = []}
|
{var $v = []}
|
||||||
{var $v = ["one"|upper => 1, 4 => $x, "three" => 3]}
|
{var $v = ["one"|upper => 1, 4 => $x, "three" => 3]}
|
||||||
{var $v = ["key1" => $y*$x-2, "key2" => ["z" => $z]]}
|
{var $v = ["key1" => $y*$x-2, "key2" => ["z" => $z]]}
|
||||||
|
```
|
||||||
|
|
||||||
Присваивание результата выполнения функции
|
Getting function result into variable
|
||||||
|
|
||||||
|
```smarty
|
||||||
{var $v = count([1,2,3])+7}
|
{var $v = count([1,2,3])+7}
|
||||||
|
```
|
||||||
|
|
||||||
|
Collect the output of the template into a variable
|
||||||
|
|
||||||
|
```smarty
|
||||||
{var $v}
|
{var $v}
|
||||||
Some long {$text|trim}
|
Some long {$text|trim}
|
||||||
{/var}
|
{/var}
|
||||||
|
Loading…
Reference in New Issue
Block a user