extro/view-engine
最新稳定版本:v1.0.0
Composer 安装命令:
composer require extro/view-engine
包简介
View engine
README 文档
README
Extro View Engine
Lightweight template engine for PHP with inheritance support.
📦 Installation
composer require extro/view-engine
🚀 Quick Start
- Create a base template: resources/views/layout.php
<!DOCTYPE html> <html> <head><?= $this->section('head') ?></head> <body> <?= $this->section() ?> </body> </html>
- Create a child template: resources/views/profile.php
<?php $this->extend('layout') ?> <?php $this->start('head') ?> <title>My profile</title> <?php $this->end() ?> <h1>Hello, <?= $this->get('name') ?>!</h1>
- Render in your code
use Extro\ViewEngine\View; use Extro\ViewEngine\ConfigInterface; // Implement your config (e.g., path to views) $config = new class implements ConfigInterface { public function getTemplateDir(): string { return __DIR__ . '/resources/views'; } }; $view = new View($config); echo $view->render('profile', ['name' => 'John']);
📚 Documentation
Template Inheritance
<!-- base.php --> <header><?= $this->section('header') ?></header> <main><?= $this->section() ?></main> <!-- page.php --> <?php $this->extend('base') ?> <?php $this->start('header') ?> Welcome Page <?php $this->end() ?> Main content goes here...
Data Handling
// Auto-escaped output (default) <?= $this->get('user_content') ?> // Raw HTML output (trusted content only) <?= $this->get('trusted_html', true) ?>
统计信息
- 总下载量: 43
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-05-02