Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Created by PhpStorm.
- * User: eni
- * Date: 17-08-25
- * Time: 8.47.MD
- */
- namespace AppBundle\Twig;
- use AppBundle\Service\MarkdownTransformer;
- class MarkdownExtension extends \Twig_Extension
- {
- private $markdownTransformer;
- public function __construct(MarkdownTransformer $markdownTransformer)
- {
- $this->markdownTransformer = $markdownTransformer;
- }
- public function getFilters()
- {
- return [
- new \Twig_SimpleFilter('markdownify', array($this, 'parseMarkdown'), [
- 'is_safe' => ['html']
- ])
- ];
- }
- public function parseMarkdown($str)
- {
- return $this->markdownTransformer->parse($str);
- }
- public function getName()
- {
- return 'app_markdown';
- }
- }
Add Comment
Please, Sign In to add comment