调整调用方式; 增加types声明
parent
a0dd900a39
commit
a5f77c6f25
|
@ -0,0 +1,19 @@
|
|||
/**
|
||||
* {}
|
||||
* @author yutent<yutent.io@gmail.com>
|
||||
* @date 2025/01/03 10:39:13
|
||||
*/
|
||||
|
||||
import Smarty from 'smartyx'
|
||||
|
||||
declare interface SmartyConfig {
|
||||
dir: string
|
||||
ext?: string
|
||||
}
|
||||
|
||||
declare interface Engine {
|
||||
name: 'smarty'
|
||||
install(conf?: SmartyConfig): Smarty
|
||||
}
|
||||
|
||||
export function createSmartyEngine(): Engine
|
10
index.js
10
index.js
|
@ -11,15 +11,16 @@ const DEFAULT_CONFIG = {
|
|||
ext: '.htm'
|
||||
}
|
||||
|
||||
export const ViewsModule = {
|
||||
name: 'views',
|
||||
export function createSmartyEngine() {
|
||||
return {
|
||||
name: 'smarty',
|
||||
install(conf = {}) {
|
||||
if (!conf.dir) {
|
||||
throw new Error('Please make sure to set the `dir` field')
|
||||
throw new Error("Smarty template's dir is required")
|
||||
}
|
||||
let views = Object.assign({}, DEFAULT_CONFIG, conf)
|
||||
let engine = new Smarty()
|
||||
|
||||
let views = Object.assign({}, DEFAULT_CONFIG, conf)
|
||||
this.set({ views })
|
||||
|
||||
engine.config('path', views.dir)
|
||||
|
@ -29,4 +30,5 @@ export const ViewsModule = {
|
|||
}
|
||||
return engine
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
{
|
||||
"name": "@gm5/views",
|
||||
"version": "2.0.0",
|
||||
"version": "3.0.0",
|
||||
"description": "@gm5框架的模板引擎拓展包",
|
||||
"type": "module",
|
||||
"main": "index.js",
|
||||
"author": "yutent <yutent.io@gmail.com>",
|
||||
"repository": "https://git.wkit.fun/gm5/views.git",
|
||||
"main": "index.js",
|
||||
"types": "index.d.ts",
|
||||
"keywords": [
|
||||
"fivejs",
|
||||
"gm5",
|
||||
|
|
Loading…
Reference in New Issue