jasonroman/twig-extension-bundle

Jason Roman's Twig Extension Bundle for Symfony2

Installs: 3 804

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:symfony-bundle

pkg:composer/jasonroman/twig-extension-bundle

1.0.3 2018-04-08 22:53 UTC

This package is not auto-updated.

Last update: 2025-10-11 20:46:39 UTC


README

Build Status

This is a class that contains Twig filters. There are 5 filters:

  • phone - displays a phone number in a specified format
  • price - essentially a PHP number_format() clone that adds '$' to the front
  • boolean - returns 'Yes'/'No' (or custom text) based on the boolean value of the variable
  • md5 - displays the md5 hash of the passed-in value
  • timeAgo - converts a time to time 'ago', such as 5 days ago, 27 seconds ago, 2 years ago

Installation

Add the bundle to your composer.json

{
    "require": {
        "jasonroman/twig-extension-bundle": "1.0.*@dev"
    }
}

Register the bundle in app/AppKernel.php

$bundles = array(
    // ...
    new JasonRoman\Bundle\TwigExtensionBundle\JasonRomanTwigExtensionBundle(),
);

Usage

{{ somePhone|phone }}
{{ someCurrency|price }}
{{ someValue|boolean }}
{{ someString|md5 }}
{{ someDate|timeAgo }}