Add 'in' modifier

This commit is contained in:
bzick 2013-02-23 17:37:04 +04:00
parent 7631e3508d
commit c45c6dc2d2
3 changed files with 28 additions and 6 deletions

View File

@ -4,7 +4,7 @@ Documentation
**Aspect**
* [About](./about.md)
* [Requirements and installation](./install.md)
* [Install](./install.md)
* [Syntax](./syntax.md)
* [Settings](./settings.md)
* [Callbacks and filters](./callbacks.md)
@ -12,23 +12,22 @@ Documentation
**Modifiers**
Conversation about [modifiers](./syntax.md#modifiers)
* [upper](./mods/upper.md) aka `up`
* [lower](./mods/lower.md) aka `low`
* [date_format](./mods/date_format.md)
* [date](./mods/date.md)
* [truncate](./mods/truncate.md)
* [escape](./mods/escape.md) aka `e`, `url`
* [escape](./mods/escape.md) aka `e`
* [unescape](./mods/unescape.md)
* [strip](./mods/strip.md)
* [length](./mods/lenght.md)
* [in](./mods/in.md)
* allowed functions: `json_encode`, `json_decode`, `count`, `is_string`, `is_array`, `is_numeric`, `is_int`, `is_object`,
`strtotime`, `gettype`, `is_double`, `ip2long`, `long2ip`, `strip_tags`, `nl2br`
**Tags**
[Using](./syntax.md#modifiers) and [addition](./ext/mods.md) of modifiers.
Conversation about [tags](./syntax.md#tags)
**Tags**
* [var](./tags/var.md)
* [if](./tags/if.md), `elseif` and `else`
@ -44,6 +43,8 @@ Conversation about [tags](./syntax.md#tags)
* [macro](./tags/macro.md)
* [import](./tags/import.md)
[Using](./syntax.md#tags) and [addition](./ext/tags.md) of tags.
**Extends**
* [Add tags](./ext/tags.md)

8
docs/mods/in.md Normal file
View File

@ -0,0 +1,8 @@
Modifier |in
============
```smarty
{if $number|in:[1, 3, 55]}
...
{/if}
```

View File

@ -129,4 +129,17 @@ class Modifier {
return count((array)$item);
}
}
/**
*
* @param $value
* @param $list
* @return bool
*/
public static function in($value, $list) {
if(is_array($list)) {
return in_array($value, $list);
}
return false;
}
}