From 957d3c00984a20b16e44ac719490bfb4562f66fb Mon Sep 17 00:00:00 2001 From: surjit Date: Thu, 29 Sep 2022 01:57:57 -0600 Subject: [PATCH] examples/entcpkg: code updated based on latest release (#2967) --- examples/entcpkg/README.md | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/examples/entcpkg/README.md b/examples/entcpkg/README.md index 1d1ac5c5c..c58473f1c 100644 --- a/examples/entcpkg/README.md +++ b/examples/entcpkg/README.md @@ -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 {