Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 

README.md

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

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

$twig->addFunction($function);
[...]

Now, in your template file/Twig file :

{{ markdown(string)|raw }}

And voila!

About

markdown function for Twig and Slim

Resources

Releases

No releases published

Packages

No packages published
You can’t perform that action at this time.