https://github.com/friendsofthinkphp/think-template-magic
ThinkPHP6 模板上加点魔法
https://github.com/friendsofthinkphp/think-template-magic
thinkphp thinkphp-component
Last synced: about 17 hours ago
JSON representation
ThinkPHP6 模板上加点魔法
- Host: GitHub
- URL: https://github.com/friendsofthinkphp/think-template-magic
- Owner: friendsofthinkphp
- License: mit
- Created: 2019-11-22T05:00:52.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-12-07T04:23:52.000Z (about 6 years ago)
- Last Synced: 2025-07-30T22:35:17.638Z (6 months ago)
- Topics: thinkphp, thinkphp-component
- Language: PHP
- Homepage:
- Size: 8.79 KB
- Stars: 5
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# think-template-magic
帮助你在模板上加点魔法
如果你项目模板很多,难于维护,可以使用此工具添加(例如全局样式,javascript,广告等等)。
只适用 ThinkPHP `6.0`
## 安装
```sh
$ composer require xiaodi/think-templte-magic
```
## 使用
例子 添加一个`css`样式
```php
head('');
}
}
```
### 配置
`config/template_magic.php`
```php
use app\Replace;
return [
'handle' => Replace::class
]
```
支持闭包
```php
use xiaodi\Contracts\TemplateMagicReplaceInterface;
return [
'handle' => function (TemplateMagicReplaceInterface $handle) {
$handle->head('');
}
];
```
### func
* `$handle->head($content)` 插入内容到``标签前
* `$handle->body($content)` 插入内容到`