Slide 33
Slide 33 text
final class ShortcodeTwigExtension extends \Twig_Extension
{
public function getFilters()
{
return [new \Twig_SimpleFilter('shortcode', [$this, 'processShortcodes'])];
}
public function processShortcodes($text)
{
$handlers = new HandlerContainer();
$handlers->add('b', new WrapHandler('', ''));
$parser = new RegularParser();
$processor = new Processor($handlers, $parser);
return $processor->process($text);
}
}