Native PHP template system: Plates

Source: Internet
Author: User
Tags php template
Plates is a native PHP template system that is very easy to use and extend, inspired by the Twig template engine, including modern template language features. Plates is primarily provided for developers who choose to use native PHP templates in the compilation template language.

Here are a simple example of what to use Plates. We'll 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 $templa Tes->render (' profile ', [' name ' = ' Jonathan ']);

The page template

profile.php

 
  Layout (' template ', [' title ' = ' User profile '])?>

User profile

Hello, E ($name)?>

The layout template

template.php

    <?= $this->e ($title)?>
 
  Section (' content ')?>


Notable features

    • Native PHP templates, no need to learn new syntax

    • Plates is a template system, not a template language

    • Plates encourages the use of existing PHP functions

    • Promoting code reusability with template layout and inheritance

    • Cross-template data sharing

    • Built-in Escape helper function

    • No fixed frame, can be used in any project

    • Decoupled design for easy testing

    • Support Composer, compatible with PSR-2

Project home:http://www.open-open.com/lib/view/home/1431008255398

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.