3 namespace Drupal\{{ machine_name }};
6 use Drupal\example\ExampleInterface;
12 class {{ class }} extends \Twig_Extension {
16 * The example service.
18 * @var \Drupal\example\ExampleInterface
23 * Constructs a new {{ class }} instance.
25 * @param \Drupal\example\ExampleInterface $example
26 * The example service.
28 public function __construct(ExampleInterface $example) {
29 $this->example = $example;
36 public function getFunctions() {
38 new \Twig_SimpleFunction('foo', function ($argument = NULL) {
39 return 'Foo: ' . $argument;
47 public function getFilters() {
49 new \Twig_SimpleFilter('bar', function ($text) {
50 return str_replace('bar', 'BAR', $text);
58 public function getTests() {
60 new \Twig_SimpleTest('color', function ($text) {
61 return preg_match('/^#(?:[0-9a-f]{3}){1,2}$/i', $text);