1. Go to this page and download the library: Download plumphp/plum-twig 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/ */
plumphp / plum-twig example snippets
use Plum\PlumTwig\TwigConverter;
$converter = new TwigConverter($twig, 'hello');
$converter->convert(['name' => 'Florian']);
$converter->setFileExtension('.twig');
$converter = new TwigConverter($twig, 'default', ['template' => 'layout']);
// The template name.html.twig is used to render the item
$converter->convert(['name' => 'Florian', 'layout' => 'name']);
$converter = new TwigConverter($twig, 'layout', ['target' => 'content']);
// The rendered template is added to the item with the key "content"
$converter->convert(['name' => 'Florian']); // -> ['name' => 'Florian', 'content' => '...']
$converter = new TwigConverter($twig, 'layout', ['context' => 'data']);
// Only the ['name' => 'Florian'] is passed as context to Twig
$converter->convert([['data' => ['name' => 'Florian'], 'file' => 'person']);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.