# think-template-magic
**Repository Path**: heehee/think-template-magic
## Basic Information
- **Project Name**: think-template-magic
- **Description**: ThinkPHP6 帮助你在模板上加点魔法
- **Primary Language**: PHP
- **License**: MIT
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2019-12-04
- **Last Updated**: 2020-12-19
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## 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)` 插入内容到`