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

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 )

Awesome Lists containing this project

README

          

# swoft-smarty

[![Latest Stable Version](https://img.shields.io/packagist/v/jxy918/swoft-smarty.svg)](https://packagist.org/packages/jxy918/swoft-smarty)
[![Php Version](https://img.shields.io/badge/php-%3E=7.1-brightgreen.svg?maxAge=2592000)](https://secure.php.net/)
[![Swoft Doc](https://img.shields.io/badge/docs-passing-green.svg?maxAge=2592000)](https://www.swoft.org/docs)
[![Swoft License](https://img.shields.io/hexpm/l/plug.svg?maxAge=2592000)](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





  • :



```