jasonroman/twig-extension-bundle

Jason Roman's Twig Extension Bundle for Symfony2

1.0.3 2018-04-08 22:53 UTC

This package is not auto-updated.

Last update: 2024-04-13 13:20:19 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 }}