examples/entcpkg: code updated based on latest release (#2967)

This commit is contained in:
surjit
2022-09-29 01:57:57 -06:00
committed by GitHub
parent fe743ccd57
commit 957d3c0098

View File

@@ -23,11 +23,9 @@ 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.
opts := []entc.Option{
entc.Funcs(template.FuncMap{"title": strings.ToTitle}),
entc.TemplateFiles("template/static.tmpl"),
}
opts := []entc.Option{}
err := entc.Generate("./schema", &gen.Config{
// Target: "./gen", If you want generated files placed under custom path
Header: `
// Copyright 2019-present Facebook Inc. All rights reserved.
// This source code is licensed under the Apache 2.0 license found
@@ -35,10 +33,13 @@ func main() {
// Code generated by ent, DO NOT EDIT.
`,
Templates: []*template.Template{
template.Must(template.New("debug").
Funcs(gen.Funcs).
ParseFiles("template/debug.tmpl")),
Templates: []*gen.Template{
// Custom templates can be provided by entc.Extension (see below),
// or by setting templates on the gen.Config object.
//
gen.MustParse(gen.NewTemplate("static").
Funcs(template.FuncMap{"title": strings.ToTitle}).
ParseFiles("./template/t1.tmpl")), // create template files under ent/template
},
}, opts...)
if err != nil {