dev-master
9999999-devMarkdown Support for Bono Based Project
MIT
The Requires
0.0.2
0.0.2.0Markdown Support for Bono Based Project
MIT
The Requires
Wallogit.com
2017 © Pedro Pelรกez
Markdown Support for Bono Based Project
This package will make you able to use markdown as Norm schema or input type markdown in your Bono Based Project., (*1)
Note: This package required PHP >5.4, (*2)
Add this package to your composer.json file, (*3)
"require": {
"krisanalfa/bono-markdown": "~0.0.1",
}
Register Bono Markdown provider to your Bono provider configuration:, (*4)
'bono.providers' => [
'Bono\\Markdown\\Provider\\MarkdownProvider' => [
'gfm' => true, // activate Github Flavored Markdown
],
],
Note: For another config options, see the Config section below., (*5)
$app = App::getInstance(); $markdown = '**Markdown is awesome**'; // render markdown syntax echo $app->container['markdown']->render($markdown); // render markdown form input echo $app->container['markdown.form']->renderInput($markdown);
Input form use Bootstrap 3 as it's theme, if you want to override this one, you should use custom view, and render your own partial template there., (*6)
Below is complete example of available option for your Markdown configuration:, (*7)
use App\MyCustomViewEngine;
'bono.providers' => [
'Bono\\Markdown\\Provider\\MarkdownProvider' => [
'gfm' => true, // default false
'service' => true, // default false
'endpoint' => '/md-parser', // default '/md'
'requestKeyName' => 'entry', // default 'markdown',
'view' => function () { // default is not set, fallback to Slim\View
return new MyCustomViewEngine;
},
'partialTemplatePath' => 'templates/partials', // default is not set, using our own partials
],
],
gfm
Enable Github Flavored Markdown, default is false, (*8)
service
If you want to enable web service that able to parse markdown set this to true, default is false, (*9)
endpoint
The endpoint URL of your web service, require service to true, default is md, (*10)
requestKeyName
The request key name for your web service, default is markdown, (*11)
view
Your custom view engine, default is Slim\View, (*12)
partialTemplatePath
Your custom partial template, default is not set (using our own partials), (*13)
You can also use this package as Norm schema. Be caution, when you call formatInput() method, the
method calls $app->container['markdown.form']->renderInput($markdown) method; the default
partial still use _markdown/form and Slim\View view engine. So, if you want to override this
behavior, you must set your own view in config file:, (*14)
'bono.providers' => [
'Bono\\Markdown\\Provider\\MarkdownProvider' => [
'view' => function() {
return new MyCustomViewEngine();
}
],
],
Note: Make sure your custom view is an extends from
Slim\View, (*15)
To enable this feature, you have to change your config, and set service to true. Access them via POST
request. This is a simple javascript example to access your webservice:, (*16)
$.ajax({
url: 'http://yourdomain.com/md',
data: {
'markdown': '**Markdown is awesome**'
},
type: 'POST'
}).done(function(html) {
$('div').html(html);
});
Note: As you see, the given URL,
/mdis based on yourendpointconfiguration., (*17)
Form input use Slim\View to fetch and load the view. If you want to change this default, you can use
$app->container['markdown.form']->setView($view)., (*18)
$view = new MyCustomViewEngine(); $app->container['markdown.form']->setView($view); // after this, form should use your custom view engine
One more. The default partials to render is _markdown/form, if you want to render another partials,
just pass a second argument in Form::renderInput() method. Example:, (*19)
$app->container['markdown.form']->renderInput($markdown, '_partials/markdown');
For more information, see Bono\Markdown\Helper\Form.php file., (*20)
Note: Your custom view should an extends from
Slim\View, (*21)
Markdown Support for Bono Based Project
MIT
Markdown Support for Bono Based Project
MIT