volta-framework/component-template
最新稳定版本:v1.0.0
Composer 安装命令:
composer require volta-framework/component-template
包简介
A HTML - PHP template module based on the PHP build in template engine.
关键字:
README 文档
README
An HTML - PHP template module based on the PHP build in template engine.
%%{init: {'theme':'dark'}}%%
classDiagram
class Volta_Component_Templates_Exception
Exception<|--Volta_Component_Templates_Exception
class Exception
class Stringable {
<<interface>>
}
class Throwable {
<<interface>>
}
StringAble..|>Throwable
Throwable..|>Exception
class Volta_Component_Templates_NotFoundException
Volta_Component_Templates_Exception<|--Volta_Component_Templates_NotFoundException
class Volta_Component_Templates_Template {
}
class Volta_Component_Templates_TemplateInterface {
<<interface>>
}
Volta_Component_Templates_TemplateInterface..|>Volta_Component_Templates_Template
class ArrayAccess {
<<interface>>
}
ArrayAccess..|>Volta_Component_Templates_Template
Stringable..|>Volta_Component_Templates_Template
class Volta_Component_Templates_View {
}
Volta_Component_Templates_Template<|--Volta_Component_Templates_View
Loading
Usage
use Volta\Component\Templates\Template as View // Set the Base Directory globally // Note: In Volta all directory references ends with a slash View::setBaseDir('/path/to/templates/directory/'); // Create a view with basic placeholders $view = new View('layout.html.php', [ 'title' => 'Unknown page' ]); // add placeholders using the set function $view->set('description', 'A simple home page') // or use array access $view['keywords'] = 'home, simple'; // add the template for the content and overwrite some off the parents // placeholders $view->addSubTemplate('content', 'content.html.php', ['title' => 'Contact']) // render the view echo $view;
layout.html.php
<?php ?> <!DOCTYPE html> <html> <head> <title><?= $this->get('title', 'No Title'); ?></title> <link rel="stylesheet" href="/assets/css/main.css"> </head> <body> <h1><?= $this['title']; ?></h1> <?= $this->getSubTemplate('content'); ?> </body> </html>
content.html.php
<?php ?> <h2><?= $this['title']; ?></h2>
统计信息
- 总下载量: 21
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-07-01