KnpMarkdownBundle/Twig/Extension/MarkdownTwigExtension.php
Joseph Bielawski 3c541b580b Removed hard dependency on MarkdownParser code, now uses dflydev/markdown library
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)`
2012-10-15 17:28:35 +02:00

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';
}
}