mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-02 11:40:56 +08:00

* v3 parser: initial work on model generation w/ templates * v3 parser: expand models to namespaces
17 lines
363 B
Cheetah
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}}
|
|
}
|
|
}
|