Documentation ¶
Index ¶
- Variables
- func Camel(s string) string
- func CatchGraphError(err *error)
- func CheckDir(dir string) error
- func CheckGraphError(err error, msg string, args ...any)
- func EscapePathElements(path string) string
- func Expect(cond bool, msg string, args ...any)
- func HasField(v any, name string) bool
- func InStrSlice(haystack []string, needle string) bool
- func IsBuildError(err error) bool
- func Join(a []string, sep string) string
- func JoinQuote(a []string, sep string) string
- func NormalizePkg(pkg string) (nlpkg string, err error)
- func ParseT(path string, templates embed.FS, funcs template.FuncMap) *gen.Template
- func Pascal(s string) string
- func Quote(v any) any
- func Snake(s string) string
- type Assets
- type GraphError
- type Template
- func (t *Template) AddParseTree(name string, tree *parse.Tree) (*Template, error)
- func (t *Template) Funcs(funcMap template.FuncMap) *Template
- func (t *Template) Parse(text string) (*Template, error)
- func (t *Template) ParseDir(path string) (*Template, error)
- func (t *Template) ParseFS(fsys fs.FS, patterns ...string) (*Template, error)
- func (t *Template) ParseFiles(filenames ...string) (*Template, error)
- func (t *Template) ParseGlob(pattern string) (*Template, error)
Constants ¶
This section is empty.
Variables ¶
var ( Funcs = template.FuncMap{ "lower": strings.ToLower, "hasPrefix": strings.HasPrefix, "hasSuffix": strings.HasSuffix, "upper": strings.ToUpper, "trim": strings.Trim, "replace": strings.ReplaceAll, "hasField": HasField, "pascal": Pascal, "base": filepath.Base, "pkgName": code.PkgShortName, "join": Join, "quote": Quote, "joinQuote": JoinQuote, } )
Functions ¶
func Camel ¶
Camel converts the given name into a camelCase.
user_info => userInfo full_name => fullName user_id => userID full-admin => fullAdmin
func CatchGraphError ¶
func CatchGraphError(err *error)
func CheckGraphError ¶
func EscapePathElements ¶
EscapePathElements breaks apart a path, and looks at each element. If it's not a path parameter, eg, {param}, it will URL-escape the element.
func InStrSlice ¶
func IsBuildError ¶
IsBuildError reports if the given error is an error from the Go command (e.g. syntax error).
func NormalizePkg ¶
Types ¶
type GraphError ¶
type GraphError struct {
// contains filtered or unexported fields
}
func (GraphError) Error ¶
func (p GraphError) Error() string
type Template ¶
Template wraps the standard template.Template to provide additional functionality for ent extensions.
func MustParse ¶
MustParse is a helper that wraps a call to a function returning (*Template, error) and panics if the error is non-nil.
func NewTemplate ¶
NewTemplate creates an empty template with the standard codegen functions.
func (*Template) AddParseTree ¶
AddParseTree adds the given parse tree to the template.
func (*Template) ParseDir ¶
ParseDir walks on the given dir path and parses the given matches with aren't Go files.
func (*Template) ParseFS ¶
ParseFS is like ParseFiles or ParseGlob but reads from the file system fsys instead of the host operating system's file system.
func (*Template) ParseFiles ¶
ParseFiles parses a list of files as templates and associate them with t. Each file can be a standalone template.