Twig templates

See the official Twig documentation for details about Twig.

Exporting functions to twig

In your public/index.php:

use Macrominds\App;
use Macrominds\DefaultConfig;
use Macrominds\Frontmatter\FrontmatterServiceProvider;
use Macrominds\MarkdownServiceProvider;
use Macrominds\TwigServiceProvider;
use Macrominds\YamlParserServiceProvider;

require_once __DIR__ . '/../vendor/autoload.php';

$app = new App(realpath(__DIR__ . '/..'));

$configuration = (new DefaultConfig())->merge([
    'template-engine' => [
        'exported'   => [
            'functions' => [
                'css' => function (string $name): string {
                    return "/css/{$name}";
                },
            ],
        ],
    ],
]);
$app->configure($configuration);
$app->registerServiceProviders([
    new FrontmatterServiceProvider($configuration),
    new YamlParserServiceProvider($configuration),
    new MarkdownServiceProvider($configuration),
    new TwigServiceProvider($configuration),
]);
$app->run();

Usage in twig template:

<link href="{{ css("/css/app.css") }}" rel="stylesheet">

Proceed with YAML and Markdown