An open API service indexing awesome lists of open source software.

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 模板上加点魔法

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)` 插入内容到`