2017 © Pedro Peláez
 

symfony-bundle twig-extensions-bundle

Twig Extensions

image

uco/twig-extensions-bundle

Twig Extensions

  • Saturday, July 28, 2012
  • by Briareos
  • Repository
  • 1 Watchers
  • 6 Stars
  • 275 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 4 Forks
  • 1 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

The UcoTwigExtensions

This bundle provides the following filters:, (*1)

  • dateage: The date filter is able to format the age of a date::, (*2)

    The post was sent {{ post.published_at | dateage }} ago., (*3)

    {# Returns 'The post was sent 5 days and 1 hour ago.' #}, (*4)

Installation

You need to install de submodule on the deps file::, (*5)

// deps
[UcoTwigExtensionsBundle]
    git=git://github.com/sgomez/UcoTwigExtensionsBundle.git
    target=/bundles/Uco/TwigExtensionsBundle

And then::, (*6)

bash$ php bin/vendors install

Configuration

Add this to app/autoload.php::, (*7)

// app/autoload.php
$loader->registerNamespaces(array(
  // ...
  'Uco'              => __DIR__.'/../vendor/bundles',
  // ...
));

And this to app/AppKernel.php::, (*8)

// app/AppKernel.php
$bundles = array(
  // ...
  new Uco\TwigExtensionsBundle\UcoTwigExtensionsBundle(),
  // ...
);

This filter uses the traslator service so, you need to activate it::, (*9)

// app/config/config.yml
framework:
    translator:      { fallback: en }

Usage

How to use::, (*10)

  • Filter dateage, (*11)

    {{ [datetime instance or string] | dateage }}, (*12)

You can also specify the timezone, the message catalog and the locale for translations::, (*13)

{{ [datetime instance or string] | dateage( *timezone*, *catalog*, *locale*) }}
{{ [datetime instance or string] | dateage("Europe/Madrid", "admin")  }}

By default, the message catalog is "TwigExtensionsDate"., (*14)

The Versions

28/07 2012

dev-master

9999999-dev https://github.com/sgomez

Twig Extensions

  Sources   Download

MIT

The Requires

 

twig symfony