library twig-markdowner
Twig extension to turn Markdown formatted text into HTML
misd/twig-markdowner
Twig extension to turn Markdown formatted text into HTML
- Tuesday, October 16, 2012
- by StuBez
- Repository
- 1 Watchers
- 4 Stars
- 39 Installations
- PHP
- 0 Dependents
- 0 Suggesters
- 0 Forks
- 0 Open issues
- 3 Versions
- 0 % Grown
TwigMarkdowner
Converts text with Markdown syntax into HTML in Twig templates., (*1)
Authors
Installation
-
Add TwigMarkdowner to your dependencies, (*2)
// composer.json
{
// ...
"require": {
// ...
"misd/twig-markdowner": "1.0.*"
}
}
-
Use Composer to download and install TwigMarkdowner, (*3)
$ php composer.phar update misd/twig-markdowner
-
Instantiate a MarkdownParser and add the extension to the Twig environment, (*4)
$parser = new \dflydev\markdown\MarkdownParser();
/** @var $twig Twig_Environment */
$twig->addExtension(new Misd\TwigMarkdowner\Twig\Extension\MarkdownerExtension($parser));
Usage
In a Twig template:, (*5)
{{ "My *Markdown* text"|markdown }}
or, (*6)
{{ object.property|markdown }}
Please note
This filter does not prevent the injection of arbitrary HTML and JavaScript; the output should be filtered (using HTMLPurifier, or equivalent) before being output in a template., (*7)