1. Go to this page and download the library: Download ergebnis/twig-front-matter library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ergebnis / twig-front-matter example snippets
declare(strict_types=1);
use Ergebnis\Twig;
$frontMatterConverter = new Twig\FrontMatter\Converter\ToMultipleAssignmentsFrontMatterConverter(true);
echo $frontMatterConverter->convert($data);
declare(strict_types=1);
use Ergebnis\Twig;
$frontMatterConverter = new Twig\FrontMatter\Converter\ToMultipleAssignmentsFrontMatterConverter(false);
echo $frontMatterConverter->convert($data);
declare(strict_types=1);
use Ergebnis\Twig;
$frontMatterConverter = new Twig\FrontMatter\Converter\ToSingleAssignmentFrontMatterConverter(
Twig\Expression\Name::fromString('data'),
false,
);
echo $frontMatterConverter->convert($data);
declare(strict_types=1);
use Ergebnis\Twig;
$frontMatterConverter = new Twig\FrontMatter\Converter\ToSingleAssignmentFrontMatterConverter(
Twig\Expression\Name::fromString('data'),
false,
);
echo $frontMatterConverter->convert($data);
declare(strict_types=1);
use Ergebnis\FrontMatter;
use Ergebnis\Twig;
use Symfony\Component\DependencyInjection;
return static function (DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->defaults()
->autoconfigure()
->autowire();
$services->alias(
FrontMatter\Parser::class,
FrontMatter\YamlParser::class,
);
$services->set(FrontMatter\YamlParser::class)
->class(FrontMatter\YamlParser::class);
$services->set(Twig\FrontMatter\Converter\FrontMatterConverter::class)
->class(Twig\FrontMatter\Converter\ToMultipleAssignmentsFrontMatterConverter::class)
->args([
'$force' => false, // or true, as you prefer
]);
$services->set(Twig\FrontMatter\FrontMatterLoader::class)
->args([
'$loader' => new DependencyInjection\Loader\Configurator\ReferenceConfigurator('twig.loader.native_filesystem'),
]);
});
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.