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 6c2a1c9a57 Merge branch '3.4' into 4.4
* 3.4:
  Enable "native_constant_invocation" CS rule
  Make AbstractPhpFileCacheWarmer public
2020-09-02 18:08:58 +02:00
..
Helper switched array() to [] 2019-01-16 10:39:14 +01:00
Loader Merge branch '3.4' into 4.4 2020-09-02 18:08:58 +02:00
Storage Replace more docblocks by type-hints 2017-11-07 15:45:01 +01:00
Tests Merge branch '3.4' into 4.4 2020-07-23 10:31:43 +02:00
.gitattributes add missing gitattributes for phpunit-bridge 2020-03-27 17:54:36 +01:00
.gitignore Added missing files .gitignore 2013-07-21 14:12:18 +02:00
CHANGELOG.md [Templating] Update changelog 2014-03-31 15:27:29 +02:00
composer.json Use ">=" for the "php" requirement 2020-05-20 10:37:50 +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 '3.4' into 4.4 2020-09-02 18:08:58 +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 Merge branch '3.4' into 4.2 2019-02-23 16:17:42 +01:00
TemplateReferenceInterface.php fixed @return when returning this or static 2016-12-27 08:23:47 +01: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