diff --git a/flextype/twig/MarkdownTwigExtension.php b/flextype/twig/MarkdownTwigExtension.php new file mode 100644 index 00000000..1958576c --- /dev/null +++ b/flextype/twig/MarkdownTwigExtension.php @@ -0,0 +1,53 @@ +flextype = $flextype; + } + + /** + * Returns a list of filters to add to the existing list. + * + * @return array + */ + public function getFilters() : array + { + return [ + new Twig_SimpleFilter('markdown', [$this, 'markdown']), + ]; + } + + /** + * Markdown process + */ + public function markdown($value) : string + { + if ($value !== null) { + return $this->flextype->markdown->text($value); + } + + return ''; + } +}