Edit app/AppKernel.php
and add a new entry to the $bundles
array:
public function registerBundles()
{
$bundles = array(
// ...
new Terrific\TwigExtensionsBundle\TerrificTwigExtensionsBundle()
// ...
);
}
Register namespace in app/autoload.php
:
$loader->registerNamespaces(array(
// ...
// 'Name' => __DIR__.'/path/to/parent/of/TwigExtensionsBundle/folder'
'Terrific' => __DIR__.'/../vendor/bundles'
// ...
));
Configuration (take a look at Service Conatiner if you want to read more about it) is done in file TwigExtensionsBundle\Resources\config\services.yml
:
services:
terrific.twig.extension.filler:
class: Terrific\TwigExtensionsBundle\Twig\Extension\FillerExtension
tags:
- { name: twig.extension }
Based on Naneau Text Filler by Maurice Fonk.
Usage:
{{ w(2) }}
to get two single random words like "Lorem ipsum".
{{ p(2) }}
to get two single random paragraphs like "Lorem ipsum dolor ..." paragraphs.
Based on Mathew Tinsley's PHP Lorem Ipsum Script. Converted to a Twig Extension by Bruno Lorenz.
Usage:
{{ textgen(2) }}
to get two randowm words like "lorem impsum." with period.