Native PHP template system: Plates is a native PHP template system, which is very easy to use and expand and is inspired by the Twig template engine, including modern template language functions. Plates is mainly provided for developers who choose to use native PHP templates in the compilation template language.
Here is a simple example of how to use Plates. We will assume the following directory stucture:
`-- path `-- to `-- templates |-- template.php |-- profile.php
Within your controller
// Create new Plates instance$templates = new League\Plates\Engine('/path/to/templates');// Render a templateecho $templates->render('profile', ['name' => 'Jonathan']);The page template
Profile. php
layout('template', ['title' => 'User Profile']) ?>User ProfileHello,
e($name)?>
The layout template
Template. php
<?=$this->e($title)?>
section('content')?>
Noteworthy features
-
Native PHP template, no need to learn new syntax
-
Plates is a template system, not a template language
-
Plates encourages the use of existing PHP functions
-
Improve code reuse by using template layout and inheritance
-
Cross-template data sharing
-
Built-in escape help functions
-
No fixed framework, which can be used in any project
-
Decoupling design, easy to test
-
Support for Composer, compatible with PSR-2
Project homepage:Http://www.open-open.com/lib/view/home/1431008255398