markdown function for Twig and Slim
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

It's a quick and dirty snippet in order to add a markdown() function to Twig with Slim Framework via Parsedown by @erusev :

require DIR_VENDORS . 'Parsedown/Parsedown.php';
$twig = $app->view()->getEnvironment();
$function = new Twig_SimpleFunction('markdown', function ($text) {
    $mkparser = new Parsedown();
    return $mkparser->text($text);


Now, in your template file/Twig file :

{{ markdown(string)|raw }}

And voila!