ibibicloud/thinkphp8-template

基于think-template=v3.0.2

0.0.1 2025-04-11 01:36 UTC

This package is auto-updated.

Last update: 2025-04-11 01:49:34 UTC


README

基于 https://github.com/top-think/think-template/tree/v3.0.2

安装

composer require ibibicloud/thinkphp8-template

文档

https://doc.thinkphp.cn/v8_0/template_engine.html https://doc.thinkphp.cn/@think-template/default.html

用法示例

<?php

namespace think;

require __DIR__.'/vendor/autoload.php';

// 设置模板引擎参数
$config = [
	'view_path'	=> './template/',
	'cache_path'	=> './runtime/',
	'view_suffix'	=> 'html',
];

$template = new Template($config);
// 模板变量赋值
$template->assign(['name' => 'think']);
// 读取模板文件渲染输出
$template->fetch('index');
// 完整模板文件渲染
$template->fetch('./template/test.php');
// 渲染内容输出
$template->display($content);

支持静态调用

use think\facade\Template;

Template::config([
	'view_path'	=> './template/',
	'cache_path'	=> './runtime/',
	'view_suffix'	=> 'html',
]);
Template::assign(['name' => 'think']);
Template::fetch('index',['name' => 'think']);
Template::display($content,['name' => 'think']);