Twig-Markdown

extend twig with markdown converter (filter/function)

3 years after

Twig-Markdown

convert markdowned text to html for Twig.

markdown converter is php-markdown-extra.

Install

Install via PEAR

Install via PEAR installer locally:

$ pear install -f package.xml

Install via PEAR installer from Corneltek PEAR channel:

$ pear install -a corneltek/Twig_Extensions_Markdown

Install via composer

Install composer in your project:

curl -s http://getcomposer.org/installer | php

Create a composer.json file in your project root:

{
    "repositories": [
        {
            "type": "package",
            "package": {
                "name": "michelf/php-markdown",
                "version": "1.0",
                "dist": {
                    "url": "https://github.com/michelf/php-markdown/zipball/extra",
                    "type": "zip"
                },
                "autoload": {
                    "files": [
                        "markdown.php"
                    ]
                }
            }
        },
        {
            "type": "vcs",
            "url": "http://github.com/geta6/Twig-Markdown"
        }
    ],
    "require": {
        "michelf/php-markdown": "1.*",
        "geta6/twig-markdown": "@dev"
    }
}

Run install command:

php composer.phar install

Usage

{% markdown %}markdownedtext{% endmarkdown %}

or

{{ markdowned|markdown|raw }}

include

# use built-in twig autoloader
require_once 'Twig/Autoloader.php';
Twig_Autoloader::register();

$debug = new \Twig_Extensions_Extension_Debug;
$twig->addExtension( $debug );

$markdown = new \Twig_Extension_Markdown;
$twig->addExtension( $markdown );

Development

To update the package.xml file, you need to install onion:

todo

むりやりincludeしてるのでもっとスマートな方法おしえてください

Related Repositories

KnpMarkdownBundle

KnpMarkdownBundle

Symfony2 wrapper for PHP markdown ...

kirby-twig

kirby-twig

Twig templating support for Kirby CMS ...

html-compress-twig

html-compress-twig

Twig extension for compressing HTML and inline CSS/JS using WyriHaximus/HtmlComp ...

Silex-Markdown

Silex-Markdown

A lightweight markdown service provider for Silex ...

doc-renderer

doc-renderer

Doc Renderer is a tool to render Markdown and RestructuredText in PHP. ...


Top Contributors

c9s geta6