mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-11 09:56:32 +00:00
d769ae90d15fe3ce8b72894935aa91d085d7bc46
This PR was merged into the 3.x branch.
Discussion
----------
Add "some" and "every" filters
This PR adds 2 new tests inspired from Javascript's functions: [some](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some) and [every](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every).
Usage :
```twig
Value {{ ([1, 2, 3] has some v => v == 2) ? 'found' : 'not found' }}
Key {{ ([1, 2, 3] has some (v, k) => k == 2) ? 'found' : 'not found' }}
Every values {{ ([1, 2, 3] has every v => 42 > v) ? 'match' : 'do not match' }}
Every keys {{ ([1, 2, 3] has every (v, k) => 42 > k) ? 'match' : 'do not match' }}
```
Commits
-------
009bb4fd Add "some" and "every" filters
Twig, the flexible, fast, and secure template language for PHP
==============================================================
Twig is a template language for PHP.
Twig uses a syntax similar to the Django and Jinja template languages which
inspired the Twig runtime environment.
Sponsors
--------
.. raw:: html
<a href="https://blackfire.io/docs/introduction?utm_source=twig&utm_medium=github_readme&utm_campaign=logo">
<img src="https://static.blackfire.io/assets/intemporals/logo/png/blackfire-io_secondary_horizontal_transparent.png?1" width="255px" alt="Blackfire.io">
</a>
More Information
----------------
Read the `documentation`_ for more information.
.. _documentation: https://twig.symfony.com/documentation
Description
Languages
PHP
99.9%