ymj666/think-smarty
最新稳定版本:1.0.0
Composer 安装命令:
composer require ymj666/think-smarty
包简介
Smarty Template driver for ThinkPHP6/ThinkPHP8
README 文档
README
ThinkPHP6/ThinkPHP8 Smarty 模板引擎驱动,使用 Smarty5 作为模板引擎
安装
composer require ymj666/think-smarty
配置
配置文件沿用了 ThinkPHP 的 view.php 配置文件,要使用 think-smarty 请先将 view.php 中的 type 配置项修改为 ThinkSmarty::class
增加和修改了几个配置项:
tpl_cache: 是否开启模板编译缓存,设为false则每次都会重新编译,默认为truetpl_cache_path: 模板编译缓存目录,对应 Smarty 的CompileDir配置,默认为runtime/tempdisplay_cache: 是否开启模板渲染缓存,设置为true则缓存过期前会直接读取渲染结果输出,默认为falsedisplay_cache_path: 模板渲染缓存目录,对应 Smarty 的CacheDir配置,默认为runtime/display_cachedisplay_cache_time: 模板渲染缓存有效期,单位:秒。设置为0则永不过期,默认为3600tpl_replace_string: 模板输出替换,是一个数组,格式为'原文本' => '替换的文本',如:'__STATIC__' => '/static'
更多配置项,请查看 ThinkSmarty.php
使用
在 Smarty 模板文件中可以直接使用 ThinkPHP 的部分助手函数,具体可查看 ThinkSmarty.php
cacheconfigcookieenvinputlangparse_namesessiontokentoken_fieldtoken_metaurlapp_pathbase_pathconfig_pathpublic_pathruntime_pathroot_path
相关链接
其他说明
代码参考了 ThinkPHP8 内置的 PHP 模板引擎
统计信息
- 总下载量: 21
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-07-11