daidepastore/slim-markdown-view

将PHP视图脚本渲染成PSR-7响应对象。

v0.1.1 2016-08-12 19:20 UTC

This package is auto-updated.

Last update: 2024-08-26 07:28:40 UTC


README

Latest version Build Status Coverage Status Quality Score Total Downloads PSR2 Conformance

将Markdown渲染成PSR-7响应对象的渲染器。它与Slim框架3配合良好。

安装

使用Composer安装

composer require davidepastore/slim-markdown-view

与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();

与任何PSR-7项目一起使用

//Construct the View
$markdownView = new MarkdownRenderer("./path/to/templates");

//Render a file
$response = $markdownView->render(new Response(), "/path/to/template.md");

自定义Parsedown实例

//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");

异常

\RuntimeException - 如果模板不存在

测试

$ phpunit

贡献

请参阅CONTRIBUTING以获取详细信息。

致谢