/** * 模板引擎拓展包 * @author yutent * @date 2020/09/27 14:17:46 */ import Smarty from 'smartyx' const DEFAULT_CONFIG = { dir: '', ext: '.htm' } export const ViewsModule = { name: 'views', install(conf = {}) { if (!conf.dir) { throw new Error('Please make sure to set the `dir` field') } let engine = new Smarty() let views = Object.assign({}, DEFAULT_CONFIG, conf) this.set({ views }) engine.config('path', views.dir) if (views.ext) { engine.config('ext', views.ext) } return engine } }