项目作者: symfony

项目描述 :
The Templating component provides all the tools needed to build any kind of template system.
高级语言: PHP
项目地址: git://github.com/symfony/templating.git
创建时间: 2011-02-22T18:07:06Z
项目社区:https://github.com/symfony/templating

开源协议:MIT License

下载


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

  1. $ composer require symfony/templating
  1. use Symfony\Component\Templating\Loader\FilesystemLoader;
  2. use Symfony\Component\Templating\PhpEngine;
  3. use Symfony\Component\Templating\Helper\SlotsHelper;
  4. use Symfony\Component\Templating\TemplateNameParser;
  5. $filesystemLoader = new FilesystemLoader(__DIR__.'/views/%name%');
  6. $templating = new PhpEngine(new TemplateNameParser(), $filesystemLoader);
  7. $templating->set(new SlotsHelper());
  8. echo $templating->render('hello.php', ['firstname' => 'Fabien']);
  9. // hello.php
  10. Hello, <?= $view->escape($firstname) ?>!

Resources