ivanamat/cakephp3-markdown
最新稳定版本:1.1
Composer 安装命令:
composer require ivanamat/cakephp3-markdown
包简介
CakePHP 3.x - Markdown
README 文档
README
Installation
Composer
You can install this plugin into your CakePHP application using composer.
The recommended way to install composer packages is:
composer require ivanamat/cakephp3-markdown
Git submodule
git submodule add git@github.com:ivanamat/cakephp3-markdown.git plugins/Markdown
git submodule init
git submodule update
Load
Component
Load component in the initialize() function
class MyController extends AppController { public function initialize() { parent::initialize(); $this->loadComponent('Markdown.Markdown'); } }
...or load the component in the array of components.
class MyController extends AppController { public $components = [ 'Markdown' => [ 'className' => 'Markdown.Markdown' ] ]; }
Helper
Load helper in the initialize() function from your View
class AppView extends View { public function initialize() { parent::initialize(); $this->loadHelper('Markdown.Markdown'); } }
Easy to use
Controller
Example: Read .md file on the controller, parse and pass html code to view.
# MyController $md = file_get_contents('../README.md', true); $html = $this->Markdown->parse($md); $this->set(compact('html'));
Helper
Example: Parse Markdown data on the view.
# MyController $md = '`This` string `is an example` of **Markdown** code'; $this->set(compact('md'));
<!-- My view.ctp -->
<?php echo $this->Markdown->parse($md); ?>
About CakePHP 3.x - Markdown
CakePHP 3.x - Markdown uses the Parsedown third-party library.
You can download Parsedown from official website: http://parsedown.org/.
Author
Iván Amat on GitHub
www.ivanamat.es
统计信息
- 总下载量: 3.87k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-08-10