ravenflux/sort-functions

Twig extension that implements sorting functions in Twig template

dev-master / 2.x-dev 2019-12-05 21:23 UTC

This package is auto-updated.

Last update: 2020-01-14 21:13:53 UTC


README

Latest Stable Version Latest Unstable Version License Total Downloads

ravenflux.jpg

Twig extension that implements sorting functions in Twig template.

Installation

The recommended way to install is via Composer:

composer require ravenflux/sort-functions

For Symfony usage, import ravenflux/sort-function services.yaml file:

# config/services.yaml
imports:
    - { resource: '../vendor/ravenflux/sort-functions/src/Resources/config/services.yaml' }

Usage

{% for user in users|usort('name') %}
    {{ user.name }}
{% endfor %}
{% for user in users|usort('name', 'DESC') %}
    {{ user.name }}
{% endfor %}