dev-master
9999999-dev https://github.com/sgomezTwig Extensions
MIT
The Requires
- php >=5.3.2
- symfony/framework-bundle 2.1.*
- twig/twig >=1.8.0
by Sergio Gómez
twig symfony
Twig Extensions
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)
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
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 }
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)
Twig Extensions
MIT
twig symfony