Slim Markdown Renderer
![Build Status][ico-travis]
![Quality Score][ico-code-quality]
, (*1)
A renderer for rendering Markdown into a PSR-7 Response object. It works well with Slim Framework 3., (*2)
Installation
Install with Composer:, (*3)
composer require davidepastore/slim-markdown-view
Usage With Slim 3
use \DavidePastore\Slim\Views\MarkdownRenderer;
include "vendor/autoload.php";
$app = new Slim\App();
$container = $app->getContainer();
$container['renderer'] = new MarkdownRenderer("./templates");
$app->get('/hello/', function ($request, $response) {
return $this->renderer->render($response, "/hello.md");
});
$app->run();
Usage with any PSR-7 Project
//Construct the View
$markdownView = new MarkdownRenderer("./path/to/templates");
//Render a file
$response = $markdownView->render(new Response(), "/path/to/template.md");
Custom Parsedown instance
//Construct the View
$parsedown = Parsedown::instance()->setUrlsLinked(false);
$markdownView = new MarkdownRenderer("./path/to/templates", $parsedown);
//Render a file
$response = $markdownView->render(new Response(), "/path/to/template.md");
Exceptions
\RuntimeException - if template does not exist, (*4)
Testing
bash
$ phpunit, (*5)
Contributing
Please see CONTRIBUTING for details., (*6)
Credits