Skip to content

Filter for Twig engine to format number into ordinal form (1st, 2nd, etc.)

License

Notifications You must be signed in to change notification settings

fvozar/twig-ordinal-number-filter

Repository files navigation

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 }

About

Filter for Twig engine to format number into ordinal form (1st, 2nd, etc.)

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages