PHP

  minte9
REMEMBERS




Last update:   20-03-2022

Templating

Component to build any kind of templating system.
 
/**
 * mkdir templating/
 * cd templating/
 * 
 * composer require symfony/templating
*/

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

use Symfony\Component\Templating\Loader\FilesystemLoader;
use Symfony\Component\Templating\PhpEngine;
use Symfony\Component\Templating\Helper\SlotsHelper;
use Symfony\Component\Templating\TemplateNameParser;

$filesystemLoader = new FilesystemLoader(__DIR__.'/views/%name%');

$templating = new PhpEngine(new TemplateNameParser(), $filesystemLoader);
$templating->set(new SlotsHelper());

echo $templating->render('hello.php', ['firstname' => 'Fabien']);

View

It provides additional tools for escaping and separating templates.
 
Hello, <?= $view->escape($firstname) ?>

Questions     github Symfony


        A B C D E F
🔔
1/1