Closed tienne closed 7 years ago
Please see the README: https://github.com/pug-php/pug#supports-for-custom-filters
And markdown is already available as a composer package: https://packagist.org/packages/pug-php/pug-filter-markdown
List of trusted available filters here: http://pug-filters.selfbuild.fr/
@kylekatarnls i see this article but my case is here
include:escaped /readme.md
but compile result
<include:escaped>/readme.md</include:escaped>
Even if it is not a custom-filters, it will compile like that
This feature is not yet released nor in pugjs neither in our port, but it will be on the next (see the project if interested https://github.com/phug-php).
Until we do this I propose you the following solution:
Install pug and the markdown filter in your app.
composer require pug-php/pug pug-php/pug-filter-markdown
Then you can use the same markdown library in a custom keyword include-markdown
:
<?php
use Pug\Pug;
use cebe\markdown\Markdown;
include __DIR__ . '/vendor/autoload.php';
$pug = new Pug(array(
'basedir' => __DIR__,
));
$pug->addKeyword('include-markdown', function ($args) use ($pug) {
$markdown = new Markdown();
return $markdown->parse(file_get_contents($pug->getOption('basedir').$args));
});
echo $pug->render('
include-markdown /readme.md
');
Just set 'basedir' => __DIR__,
with the directory that contains readme.md.
Hope this solve your problem, if not fell free to re-open this issue with failure details.
Hi, this syntax is now supported with the version 3.0.0, hope you will envoy this new version.
oh sorry, i see now this comment thank you!
i want pugs includeing filter include:markdown /readme.md
https://pugjs.org/language/includes.html#including-filtered-text
but this compile