65f2620bc4
* 4.4: fix merge Remove branch-version (keep them for contracts only) [HttpClient] relax auth bearer format requirements [PHPUnitBridge] Silence errors from mkdir() [DependencyInjection] Preload classes with union types correctly. [Serializer] fix decoding float XML attributes starting with 0 add missing dutch translations Support PHPUnit 8 and PHPUnit 9 in constraint compatibility trait Add expectDeprecation, expectNotice, expectWarning, and expectError to TestCase polyfill Add missing exporter function for PHPUnit 7 [Validator] Add missing romanian translations [Cache] Use correct expiry in ChainAdapter do not translate null placeholders or titles |
||
---|---|---|
.. | ||
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) ?>!