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 28f1ab67ca Merge branch '4.4' into 5.1
* 4.4:
  Use createMock() and use import instead of FQCN
2021-01-27 11:01:46 +01:00
..
Helper Merge branch '4.4' into 5.1 2020-12-27 14:04:50 +01: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.1 2021-01-27 11:01:46 +01: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 2021-01-10 17:29:19 +01: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 Bump license year 2021-01-01 10:24:35 +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