mirror of
https://github.com/KnpLabs/KnpMarkdownBundle.git
synced 2024-06-08 08:52:21 +02:00
33 lines
675 B
PHP
33 lines
675 B
PHP
<?php
|
|
|
|
namespace Knp\Bundle\MarkdownBundle\Twig\Extension;
|
|
|
|
use Knp\Bundle\MarkdownBundle\Helper\MarkdownHelper;
|
|
|
|
class MarkdownTwigExtension extends \Twig_Extension
|
|
{
|
|
protected $helper;
|
|
|
|
public function __construct(MarkdownHelper $helper)
|
|
{
|
|
$this->helper = $helper;
|
|
}
|
|
|
|
public function getFilters()
|
|
{
|
|
return array(
|
|
new \Twig_SimpleFilter('markdown', array($this, 'markdown'), array('is_safe' => array('html'))),
|
|
);
|
|
}
|
|
|
|
public function markdown($text, $parser = null)
|
|
{
|
|
return $this->helper->transform($text, $parser);
|
|
}
|
|
|
|
public function getName()
|
|
{
|
|
return 'markdown';
|
|
}
|
|
}
|