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 b72e9c28da Merge branch '5.1'
* 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
2020-07-23 10:36:44 +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.0 2020-03-15 15:33:06 +01: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 '5.1' 2020-05-20 19:44:07 +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.0 2020-03-15 15:33:06 +01: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