Git Product home page Git Product logo

twig-byte-units-extension's Introduction

Byte Units Twig extension

Build Status Code Coverage Downloads Latest stable License

This package provides simple Twig filters that wrap ByteUnits lib by Gabriele Lana which makes manipulation with informational units very easy.

Installation

To install this extension, use Composer:

composer require marioblazek/twig-byte-units-extension

Using the extension

In PHP:

$twig = new Twig_Environment($loader, $options);

$twig->addExtension(new Marek\Twig\ByteUnitsExtension());

In a Symfony project, you can register the extension as a service:

services:
    twig.extension.byte_units:
        class: Marek\Twig\ByteUnitsExtension
        tags:
            - { name: twig.extension }

Once set up, you can use the following Twig filters:

  • 1322000|byte_units_format_metric('MB') - Returns value formated in MB as returned by ByteUnits\Metric::format method
  • 1322000|byte_units_format_binary('MB') - Returns value formated in MiB as returned by ByteUnits\Binary::format method
  • 1322000|byte_units_bytes_metric - Returns the number of bytes as string returned by ByteUnits\Metric::numberOfBytes method
  • 1322000|byte_units_bytes_binary - Returns the number of bytes as string returned by ByteUnits\Binary::numberOfBytes method

for more information please check formating section on byte-units repo.

twig-byte-units-extension's People

Contributors

djoos avatar marioblazek avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

twig-byte-units-extension's Issues

Support for PHP 8?

Hi there,

are there plans to add in support for PHP 8 for this Twig extension?

Thanks in advance!

Kind regards,
David

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.