How to properly use Markdown in Phalcon. I found this code;
$di->set('view', function() {
$view = new \Phalcon\Mvc\View();
$view->setViewsDir('../app/views/');
$view->registerEngines([
'.md' => function($view, $di) {
$md = new \Phalcon\Mvc\View\Engine\Markdown($view, $di);
$md->setOptions([
'compiledPath' => '../app/compiled-templates/',
'compiledSeparator' => '_',
'renderFlags' => [ 'special-attribute', 'line-continue' ],
]);
return $md;
}
]);
return $view;
});
Source: https://hiden.samurai-factory.jp/php/phalcon_markdown/
This is the code I'm using:
use Phalcon\Mvc\View,
Phalcon\Mvc\View\Engine\Volt,
Phalcon\Mvc\View\Engine\Markdown;
$di->set('view', function() use ($config) {
$view = new View();
$view->setViewsDir($config->phalcon->views);
$view->registerEngines(array(
'.phtml' => function($view, $di) use ($config) {
$volt = new Volt($view, $di);
$volt->setOptions([
'compiledPath' => $config->phalcon->cache,
'compiledExtension' => '.compiled',
'compileAlways' => true,
'stat' => true
]);
return $volt;
},
'.md' => function($view, $di) use ($config) {
$md = new Markdown($view, $di);
$md->setOptions([
'compiledPath' => $config->phalcon->cache,
'compiledSeparator' => '_',
'renderFlags' => [ 'special-attribute', 'line-continue' ],
]);
return $md;
}
));
return $view;
});
But all I see is blank page. Even my old phtml files that use volt don't work now. Is Markdown adapter comes with Phalcon or it needs to be compiled and included seperately ? Note that I would like to use both Volt and Markdown views. Thanks.