This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Component/Templating
Nicolas Grekas 65f2620bc4 Merge branch '4.4' into 5.1
* 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
2020-10-24 14:01:57 +02:00
..
Helper [Templating] Added type-hints to all classes. 2019-07-06 21:20:42 +02:00
Loader Merge branch '4.4' into 5.1 2020-09-02 18:23:27 +02:00
Storage Replace more docblocks by type-hints 2017-11-07 15:45:01 +01:00
Tests Merge branch '4.4' into 5.0 2020-07-23 10:36:09 +02:00
.gitattributes add missing gitattributes for phpunit-bridge 2020-03-27 17:54:36 +01:00
.gitignore
CHANGELOG.md
composer.json Merge branch '4.4' into 5.1 2020-10-24 14:01:57 +02:00
DelegatingEngine.php switched array() to [] 2019-01-16 10:39:14 +01:00
EngineInterface.php switched array() to [] 2019-01-16 10:39:14 +01:00
LICENSE Update year in license files 2020-01-01 12:03:25 +01:00
PhpEngine.php Merge branch '4.4' into 5.1 2020-09-02 18:23:27 +02:00
phpunit.xml.dist Bump phpunit XSD version to 5.2 2018-11-11 12:18:13 +01:00
README.md [DotEnv][WebLink][Templating][ErrorHandler] Updated README with minimal example 2020-05-26 11:42:42 +02:00
StreamingEngineInterface.php switched array() to [] 2019-01-16 10:39:14 +01:00
TemplateNameParser.php Merge branch '2.3' into 2.7 2015-09-29 14:06:14 +02:00
TemplateNameParserInterface.php Merge branch '2.3' into 2.7 2015-09-29 14:06:14 +02:00
TemplateReference.php [Templating] Added type-hints to all classes. 2019-07-06 21:20:42 +02:00
TemplateReferenceInterface.php [Templating] Added type-hints to all classes. 2019-07-06 21:20:42 +02:00

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