Skip to content

Latest commit

 

History

History
32 lines (26 loc) · 827 Bytes

README.md

File metadata and controls

32 lines (26 loc) · 827 Bytes

Twig OrdinalNumber Extension

Build Status

A Twig Extension filter to format number into ordinal form (1st, 2nd, etc.).

Install

With composer

composer require fvozar/twig-ordinal-number-filter

Usage

Basic usage is just put ordinal filter on your number.

{{ someNumber | ordinal }}

You can also provide another locale for internally used \NumberFormatter class

{{ someNumber | ordinal('sk') }}

For Symfony usage you'll want to add it as a service and tag it for Twig.

# app/config/services.yml
services:
    twig.extension.ordinal:
        class: Fvozar\Twig\OrdinalNumberExtension
        tags:
            - { name: twig.extension }