b72e9c28da
* 5.1: fix merge Require PHPUnit 9.3 on PHP 8 [Cache] fix catching auth errors Fix CS [FrameworkBundle] set default session.handler alias if handler_id is not provided Fix CS Readability update Removed @internal from Composite Fix checks for phpunit releases on Composer 2 (resolves #37601) [Messenger] fix ignore account & endpoint options amazon sqs connection [Serializer] Support multiple levels of discriminator mapping Use hexadecimal numerals instead of hexadecimals in strings to represent error codes. [SCA] Minor fixes on tests [WebProfilerBundle] modified url generation to use absolute urls [Mailer] Fix reply-to functionality in the SendgridApiTransport [Mime] Fix compat with HTTP requests ticket_36879 - Fix mandrill raw http request setting from email/name |
||
---|---|---|
.. | ||
Helper | ||
Loader | ||
Storage | ||
Tests | ||
.gitattributes | ||
.gitignore | ||
CHANGELOG.md | ||
composer.json | ||
DelegatingEngine.php | ||
EngineInterface.php | ||
LICENSE | ||
PhpEngine.php | ||
phpunit.xml.dist | ||
README.md | ||
StreamingEngineInterface.php | ||
TemplateNameParser.php | ||
TemplateNameParserInterface.php | ||
TemplateReference.php | ||
TemplateReferenceInterface.php |
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) ?>!