https://github.com/jxy918/swoft-smarty
sowft框架smarty模板组件(Sawft framework smart template component )
https://github.com/jxy918/swoft-smarty
php smarty swoft swoft-ddz swoft-game swoft-smarty swoole
Last synced: 9 months ago
JSON representation
sowft框架smarty模板组件(Sawft framework smart template component )
- Host: GitHub
- URL: https://github.com/jxy918/swoft-smarty
- Owner: jxy918
- Created: 2019-08-19T08:22:32.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-10-24T08:25:18.000Z (over 6 years ago)
- Last Synced: 2024-09-01T12:38:57.716Z (almost 2 years ago)
- Topics: php, smarty, swoft, swoft-ddz, swoft-game, swoft-smarty, swoole
- Language: PHP
- Homepage:
- Size: 42 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# swoft-smarty
[](https://packagist.org/packages/jxy918/swoft-smarty)
[](https://secure.php.net/)
[](https://www.swoft.org/docs)
[](https://github.com/swoft-cloud/swoft/blob/master/LICENSE)
sowft框架smarty模板组件
smarty template component for swoft.
Swoft-smarty Component
## Install, 安装
- composer install command
```
composer require jxy918/swoft-smarty
```
- smarty default config
- swoft框架里 smarty 的默认配置如下, 默认不需要添加, 如果想要修改, 可以把下面配置放入到bean.php里面, 进行相应的修改即可
```
'smarty' => [
'debugging'=>true,
'caching'=>true,
'cacheLifetime'=>120,
'leftDelimiter' => '',
'templateDir' => '@base/resource/template',
'compileDir' => '@base/runtime/template_c',
'cacheDir' => '@base/runtime/cache'
]
```
## Use in Controller, 控制器里使用如下
- app/Http/Controlle/SmartyController.php
- resource/template/smarty.html
app/Http/Controlle/SmartyController.php
```
initView();
$data = ['nickname'=>'jxy918', 'sex'=>'男', 'msg'=>' hello smarty'];
$tpl->assign('data', $data);
$content = $tpl->fetch('smarty.html');
return context()->getResponse()->withContentType(ContentType::HTML)->withContent($content);
}
}
```
模板文件 resource/template/smarty.html
```
test smayrt
Hello Smarty
- :
```