mirror of
https://github.com/fenom-template/fenom.git
synced 2023-08-10 21:13:07 +03:00
Fix {switch} and ternary operator
This commit is contained in:
@@ -30,7 +30,6 @@ $fenom->setOptions($options);
|
||||
* **auto_escape**, `Fenom::AUTO_ESCAPE`, все выводящие переменные и результаты функций будут экранироваться
|
||||
* **auto_trim**, `Fenom::AUTO_TRIM`, при компиляции, все пробельные символы между тегами будут удлаены.
|
||||
* **force_verify**, `Fenom::FORCE_VERIFY`, проверять обращение каждой переменной и возвращать NULL если переменной не существует.
|
||||
* **deny_static_methods**, `Fenom::DENY_STATIC_METHODS`, отключает возможность вызова статичных методов в шаблоне.
|
||||
|
||||
```php
|
||||
$fenom->setOptions(array(
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
Tag {switch}
|
||||
============
|
||||
|
||||
The `{switch}` tag is similar to a series of `{if}` statements on the same expression.
|
||||
In many occasions, you may want to compare the same variable (or expression) with many different values,
|
||||
and execute a different piece of code depending on which value it equals to. This is exactly what the `{switch}` tag is for.
|
||||
|
||||
Tag `{switch}` accepts any expression. But `{case}` accepts only static scalar values or constants.
|
||||
|
||||
```smarty
|
||||
{switch <condition>}
|
||||
{case <value1>}
|
||||
@@ -9,7 +15,7 @@ Tag {switch}
|
||||
...
|
||||
{case <value3>}
|
||||
...
|
||||
{default}
|
||||
{default case <value1>}
|
||||
...
|
||||
{/switch}
|
||||
```
|
||||
@@ -24,14 +30,14 @@ For example,
|
||||
It is new or current item
|
||||
{case 'current'}
|
||||
It is current item
|
||||
{case 'new'}
|
||||
{case 'new', $.const.NEW_STATUS}
|
||||
It is new item, again
|
||||
{default}
|
||||
I don't know the type {$type}
|
||||
{/switch}
|
||||
```
|
||||
|
||||
set `$type = 'new'`, then template output
|
||||
if `$type = 'new'` then template output
|
||||
|
||||
```
|
||||
It is new item
|
||||
|
||||
Reference in New Issue
Block a user