mirror of
https://github.com/KnpLabs/KnpMarkdownBundle.git
synced 2024-05-04 14:43:17 +02:00
3c541b580b
Refactored way how parsers are initialized, and allow to select parser while rendering Interface `MarkdownParserInterface` method name was changed from `#transform($text)` to `#transformMarkdown($text)`
33 lines
664 B
PHP
33 lines
664 B
PHP
<?php
|
|
|
|
namespace Knp\Bundle\MarkdownBundle\Twig\Extension;
|
|
|
|
use Knp\Bundle\MarkdownBundle\Helper\MarkdownHelper;
|
|
|
|
class MarkdownTwigExtension extends \Twig_Extension
|
|
{
|
|
protected $helper;
|
|
|
|
function __construct(MarkdownHelper $helper)
|
|
{
|
|
$this->helper = $helper;
|
|
}
|
|
|
|
public function getFilters()
|
|
{
|
|
return array(
|
|
'markdown' => new \Twig_Filter_Method($this, 'markdown', array('is_safe' => array('html'))),
|
|
);
|
|
}
|
|
|
|
public function markdown($text, $parser = null)
|
|
{
|
|
return $this->helper->transform($text, $parser);
|
|
}
|
|
|
|
public function getName()
|
|
{
|
|
return 'markdown';
|
|
}
|
|
}
|