2017 © Pedro Peláez
 

library twig-extension-number

image

pnz/twig-extension-number

  • Sunday, February 19, 2017
  • by thepanz
  • Repository
  • 1 Watchers
  • 3 Stars
  • 9,418 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 1 Open issues
  • 4 Versions
  • 13 % Grown

The README.md

Twig-Extension-Number

Latest Stable Version Total Downloads Latest Unstable Version License Scrutinizer Code Quality, (*1)

A Twig extension to handle number formatting., (*2)

Included filters: - format_bytes Formats the given amount as bytes and display it in an as a human-readable format. The filter supports 1000/1024 base counting and formatting - format_grams Formats the given amount as "grams" in a human-readable format - format_meters Formats the given amount as "meters" in a human-readable format, (*3)

Examples

Display the value of 4000 grams in a human-readable format (4.00 Kg):, (*4)

{{ 4000 | format_grams }}

The filter allows some customization of the output, given its signature filter_grams(decimals, unityBias): * Decimals: Display the value of 4000 grams in a human-readable format with 3 decimals (4.000 Kg): {{ 4000 | format_grams(3) }} * UnityBias: Set the filter to handle the number as being expressed with a different bias then the standard unit (grams). To display the value of 4000 (expressed in milligrams, 1E-3) as grams in a human-readable format with 3 decimals (4.00 g) use: {{ 4000 | format_grams(3, 1E-3) }}, (*5)

Install

Via composer:, (*6)

    composer require "pnz/twig-extension-number"

In Symfony, tag Pnz\TwigExtensionNumber\Number with twig.extension, and the filter will be automatically registered., (*7)

    # file: config/services.yaml
    Pnz\TwigExtensionNumber\Number:
        tags: ['twig.extension']

The Versions

19/02 2017

1.x-dev

1.9999999.9999999.9999999-dev https://github.com/thePanz/Twig-Extension-Number

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar thepanz

i18n number

19/02 2017
13/09 2015

1.0.1

1.0.1.0 https://github.com/thePanz/Twig-Extension-Number

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar thepanz

i18n number

14/03 2015

1.0.0

1.0.0.0 https://github.com/thePanz/Twig-Extension-Number

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar thepanz

i18n number