views/index.js

29 lines
513 B
JavaScript
Raw Normal View History

2020-09-27 18:37:49 +08:00
/**
* 模板引擎拓展包
* @author yutent<yutent.io@gmail.com>
* @date 2020/09/27 14:17:46
*/
import Smarty from 'smartyx'
2023-10-27 19:18:41 +08:00
export function createViewsPlugin() {
return {
name: 'views',
install() {
let eng = new Smarty()
let conf = this.get('views')
2020-09-27 19:33:57 +08:00
if (conf.dir) {
eng.config('path', conf.dir)
if (conf.ext) {
eng.config('ext', conf.ext)
}
return eng
} else {
throw new Error('views.dir is empty')
}
}
2020-09-27 18:37:49 +08:00
}
}