--- /dev/null
+<?php
+
+namespace Drupal\{{ machine_name }};
+
+/**
+ * Twig extension.
+ */
+class {{ class }} extends \Twig_Extension {
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getName() {
+ return '{{ machine_name }}';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getFunctions() {
+ return [
+ new \Twig_SimpleFunction('foo', function ($argument = NULL) {
+ return 'Foo: ' . $argument;
+ }),
+ ];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getFilters() {
+ return [
+ new \Twig_SimpleFilter('bar', function ($text) {
+ return str_replace('bar', 'BAR', $text);
+ }),
+ ];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getTests() {
+ return [
+ new \Twig_SimpleTest('color', function ($text) {
+ return preg_match('/^#(?:[0-9a-f]{3}){1,2}$/i', $text);
+ }),
+ ];
+ }
+
+}