mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
examples/entcpkg: code updated based on latest release (#2967)
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user