5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-02 14:59:25 +08:00
wails/v3/internal/parser/templates/class.ts.tmpl
Adam Tenderholt da90e74268
v3 parser: initial work on model generation w/ templates (#2428)
* v3 parser: initial work on model generation w/ templates

* v3 parser: expand models to namespaces
2023-02-28 20:35:18 +11:00

17 lines
363 B
Cheetah

export class {{.Name}} {
{{range .Fields}}{{.}}
{{end}}
static createFrom(source: any = {}) {
return new {{.Name}}(source);
}
constructor(source: any = {}) {
if ('string' === typeof source) {
source = JSON.parse(source);
}
{{range .Fields}}this.{{jsName .}} = source["{{jsName .}}"]
{{end}}
}
}