mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
entc/gen: adding tagLookup / strings.Split functions to template engine
Signed-off-by: Alex Snast <alexsn@fb.com>
This commit is contained in:
@@ -51,6 +51,8 @@ var (
|
||||
"trimPackage": trimPackage,
|
||||
"xtemplate": xtemplate,
|
||||
"hasTemplate": hasTemplate,
|
||||
"split": strings.Split,
|
||||
"tagLookup": tagLookup,
|
||||
}
|
||||
rules = ruleset()
|
||||
acronym = make(map[string]bool)
|
||||
@@ -306,3 +308,9 @@ func indirect(v reflect.Value) reflect.Value {
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// tagLookup returns the value associated with key in the tag string.
|
||||
func tagLookup(tag, key string) string {
|
||||
v, _ := reflect.StructTag(tag).Lookup(key)
|
||||
return v
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user