Skip to content

misd-service-development/twig-markdowner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

TwigMarkdowner

Converts text with Markdown syntax into HTML in Twig templates.

Authors

Installation

  1. Add TwigMarkdowner to your dependencies

     // composer.json
    
     {
         // ...
         "require": {
             // ...
             "misd/twig-markdowner": "1.0.*"
         }
     }
    
  2. Use Composer to download and install TwigMarkdowner

     $ php composer.phar update misd/twig-markdowner
    
  3. Instantiate a MarkdownParser and add the extension to the Twig environment

     $parser = new \dflydev\markdown\MarkdownParser();
    
     /** @var $twig Twig_Environment */
     $twig->addExtension(new Misd\TwigMarkdowner\Twig\Extension\MarkdownerExtension($parser));
    

Usage

In a Twig template:

    {{ "My *Markdown* text"|markdown }}

or

    {{ 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.

About

Twig extension to turn Markdown formatted text into HTML

Resources

Stars

Watchers

Forks

Packages

No packages published