Skip to content

symfony/templating

Folders and files

NameName
Last commit message
Last commit date

Latest commit

e27b6ea · Oct 25, 2024
Sep 25, 2024
Jul 30, 2023
Oct 25, 2024
Jul 30, 2023
May 17, 2024
Sep 25, 2024
Jul 21, 2013
Jul 30, 2023
Jul 30, 2023
Jul 30, 2023
Jan 24, 2023
Jan 23, 2024
May 26, 2021
Sep 25, 2023
Jul 30, 2023
Jul 30, 2023
Jan 23, 2024
Jul 30, 2023
Jul 30, 2023
Jun 2, 2021

Repository files navigation

Templating Component

The Templating component provides all the tools needed to build any kind of template system.

It provides an infrastructure to load template files and optionally monitor them for changes. It also provides a concrete template engine implementation using PHP with additional tools for escaping and separating templates into blocks and layouts.

Getting Started

$ composer require symfony/templating
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']);

// hello.php
Hello, <?= $view->escape($firstname) ?>!

Resources