Add some things to template functions.
This commit is contained in:
parent
225a74423a
commit
f764c979e7
1 changed files with 4 additions and 1 deletions
|
@ -105,12 +105,12 @@ var templateStringMappers = map[string]func(string) string{
|
||||||
// add a function pointer here.
|
// add a function pointer here.
|
||||||
var templateFunctions = template.FuncMap{
|
var templateFunctions = template.FuncMap{
|
||||||
// String ops
|
// String ops
|
||||||
"substring": strmangle.Substring,
|
|
||||||
"trimPrefix": func(pre, str string) string { return strings.TrimPrefix(str, pre) },
|
"trimPrefix": func(pre, str string) string { return strings.TrimPrefix(str, pre) },
|
||||||
"remove": func(rem, str string) string { return strings.Replace(str, rem, "", -1) },
|
"remove": func(rem, str string) string { return strings.Replace(str, rem, "", -1) },
|
||||||
"replace": func(rep, with, str string) string { return strings.Replace(str, rep, with, -1) },
|
"replace": func(rep, with, str string) string { return strings.Replace(str, rep, with, -1) },
|
||||||
"prefix": func(add, str string) string { return fmt.Sprintf("%s%s", add, str) },
|
"prefix": func(add, str string) string { return fmt.Sprintf("%s%s", add, str) },
|
||||||
"quoteWrap": func(a string) string { return fmt.Sprintf(`"%s"`, a) },
|
"quoteWrap": func(a string) string { return fmt.Sprintf(`"%s"`, a) },
|
||||||
|
"substring": strmangle.Substring,
|
||||||
"id": strmangle.Identifier,
|
"id": strmangle.Identifier,
|
||||||
|
|
||||||
// Pluralization
|
// Pluralization
|
||||||
|
@ -136,6 +136,9 @@ var templateFunctions = template.FuncMap{
|
||||||
// Database related mangling
|
// Database related mangling
|
||||||
"whereClause": strmangle.WhereClause,
|
"whereClause": strmangle.WhereClause,
|
||||||
|
|
||||||
|
// Text helpers
|
||||||
|
"textsFromRelationship": textsFromRelationship,
|
||||||
|
|
||||||
// dbdrivers ops
|
// dbdrivers ops
|
||||||
"driverUsesLastInsertID": strmangle.DriverUsesLastInsertID,
|
"driverUsesLastInsertID": strmangle.DriverUsesLastInsertID,
|
||||||
"makeDBName": strmangle.MakeDBName,
|
"makeDBName": strmangle.MakeDBName,
|
||||||
|
|
Loading…
Reference in a new issue