From 42bbb63e9759fed18268e6e38ee0feac408c71bb Mon Sep 17 00:00:00 2001 From: Casey McLaughlin Date: Thu, 22 Jan 2015 17:18:46 -0500 Subject: [PATCH] Added 'add_anchors' Twig function. --- src/TocTwigExtension.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/TocTwigExtension.php b/src/TocTwigExtension.php index ffc1ba5..6d39121 100644 --- a/src/TocTwigExtension.php +++ b/src/TocTwigExtension.php @@ -94,6 +94,10 @@ class TocTwigExtension extends Twig_Extension return $this->generator->getMenu($markup, $top, $depth); }); + $functions[] = new \Twig_SimpleFunction('add_anchors', function($markup, $top = 1, $depth =2) { + return $this->fixer->fix($markup, $top, $depth); + }, ['is_safe' => ['html']]); + return $functions; }