定制 leonickl/plate 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

leonickl/plate

Composer 安装命令:

composer require leonickl/plate

包简介

A PHP templating engine

README 文档

README

Plate

Plate

A lightweight PHP templating engine inspired by Laravel's Blade.

Features

  • Simple, expressive syntax with {{ }} delimiters
  • Automatic output escaping for security
  • Conditional rendering with if, elif, and else
  • Loop support with each
  • Raw PHP execution within templates
  • Compiles to plain PHP for optimal performance

Requirements

  • PHP >= 8.4

Installation

composer require leonickl/plate

Usage

<?php

require 'vendor/autoload.php';

use LeoNickl\Plate\Plate;

// Compile a .plate file to PHP code
$phpCode = Plate::file('view.plate');

// Cast to string to get the compiled PHP
echo (string) $phpCode;

Template Syntax

Printing Values

{{ "hello" }}              // Escaped output
{{ % $html }}              // Unescaped output
{{ "hello", "world" }}     // Multiple expressions (joined with space)

Execute PHP statement

{{ :$var = "test" }}       // Execute PHP without printing

Conditionals

{{ if: $condition }}
    <p>Yes!</p>
{{ elif: $other }}
    <p>Maybe!</p>
{{ else: }}
    <p>No!</p>
{{ if; }}

Loops

{{ each: $items as $item }}
    <p>{{ $item }}</p>
{{ each; }}

Import Components

{{ plug: 'nav' }}
{{ plug: 'person', data: $person }}

In order for this to work, you need to define this function and adjust it to your environment:

function plug_plate(string $file, mixed ...$params): string
{
    return view($file, $params); // or however you import your views
}

Example

See example.plate for a complete example. Run it with:

php index.php | php

This compiles the template and executes the resulting PHP.

Syntax Highlighting

Available for VSCode leonickl/plate-vscode

统计信息

  • 总下载量: 107
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2026-04-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固