5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-04 12:51:38 +08:00
wails/v3/internal/generator/render/templates.go
Fabio Massaioli f01b4b9a21
[v3] Fix binding generator bugs (#4001)
* Add some clarifying comments

* Remove special handling of window parameters

* Improve internal method exclusion

* Add test for internal method exclusion

* Remove useless blank field from app options

This is a leftover from an older version of the static analyser. It should have been removed long ago.

* Remove redundant godebug setting

gotypesalias=1 is the default starting with go1.23

* Use new range for syntax to simplify code

* Remove generator dependency on github.com/samber/lo

* Ensure generator testing tasks do not use the test cache

* Rename cyclic types test

* Test for cyclic imports

* Fix import cycle between model files

* Sort class aliases after their aliased class

* Test class aliases

* Fix length of default value for array types

* Test array initialization

* Add changelog

* Update changelog

* Fix contrived marking technique in model sorting algorithm

* Update binding example

* Update test data

---------

Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
2025-01-17 18:56:07 +11:00

42 lines
1.3 KiB
Go

package render
import (
"embed"
"strings"
"text/template"
)
//go:embed templates/*.tmpl
var templates embed.FS
type tmplLanguage bool
const tmplJS, tmplTS tmplLanguage = false, true
var tmplService = map[tmplLanguage]*template.Template{
tmplJS: template.Must(template.New("service.js.tmpl").Funcs(tmplFunctions).ParseFS(templates, "templates/service.js.tmpl")),
tmplTS: template.Must(template.New("service.ts.tmpl").Funcs(tmplFunctions).ParseFS(templates, "templates/service.ts.tmpl")),
}
var tmplTypedefs = map[tmplLanguage]*template.Template{
tmplJS: template.Must(template.New("internal.js.tmpl").Funcs(tmplFunctions).ParseFS(templates, "templates/internal.js.tmpl")),
tmplTS: template.Must(template.New("internal.ts.tmpl").Funcs(tmplFunctions).ParseFS(templates, "templates/internal.ts.tmpl")),
}
var tmplModels = template.Must(template.New("models.tmpl").Funcs(tmplFunctions).ParseFS(templates, "templates/models.tmpl"))
var tmplIndex = template.Must(template.New("index.tmpl").Funcs(tmplFunctions).ParseFS(templates, "templates/index.tmpl"))
var newline string
func init() {
var builder strings.Builder
err := template.Must(template.New("newline.tmpl").ParseFS(templates, "templates/newline.tmpl")).Execute(&builder, nil)
if err != nil {
panic(err)
}
newline = builder.String()
}