mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
entc/gen: add gen.Template for ent extensions (#859)
This commit is contained in:
@@ -18,10 +18,9 @@ import (
|
||||
func main() {
|
||||
// A usage for custom templates with external functions.
|
||||
// One template is defined in the option below, and the
|
||||
// second template is provided with the `Templates` field.
|
||||
// second template is provided with the `Templates` option.
|
||||
opts := []entc.Option{
|
||||
entc.Funcs(template.FuncMap{"title": strings.ToTitle}),
|
||||
entc.TemplateFiles("template/static.tmpl"),
|
||||
entc.TemplateFiles("template/debug.tmpl"),
|
||||
}
|
||||
err := entc.Generate("./schema", &gen.Config{
|
||||
Header: `
|
||||
@@ -31,10 +30,10 @@ func main() {
|
||||
|
||||
// Code generated by entc, DO NOT EDIT.
|
||||
`,
|
||||
Templates: []*template.Template{
|
||||
template.Must(template.New("debug").
|
||||
Funcs(gen.Funcs).
|
||||
ParseFiles("template/debug.tmpl")),
|
||||
Templates: []*gen.Template{
|
||||
gen.MustParse(gen.NewTemplate("static").
|
||||
Funcs(template.FuncMap{"title": strings.ToTitle}).
|
||||
ParseFiles("template/static.tmpl")),
|
||||
},
|
||||
}, opts...)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user