Ejemplo n.º 1
0
func init() {
	funcMap = template.FuncMap{
		"urlize":      helpers.URLize,
		"sanitizeURL": helpers.SanitizeURL,
		"sanitizeurl": helpers.SanitizeURL,
		"eq":          Eq,
		"ne":          Ne,
		"gt":          Gt,
		"ge":          Ge,
		"lt":          Lt,
		"le":          Le,
		"in":          In,
		"slicestr":    Slicestr,
		"substr":      Substr,
		"split":       Split,
		"intersect":   Intersect,
		"isSet":       IsSet,
		"isset":       IsSet,
		"echoParam":   ReturnWhenSet,
		"safeHTML":    SafeHTML,
		"safeCSS":     SafeCSS,
		"safeURL":     SafeURL,
		"absURL":      func(a string) template.HTML { return template.HTML(helpers.AbsURL(a)) },
		"relURL":      func(a string) template.HTML { return template.HTML(helpers.RelURL(a)) },
		"markdownify": Markdownify,
		"first":       First,
		"last":        Last,
		"after":       After,
		"where":       Where,
		"delimit":     Delimit,
		"sort":        Sort,
		"highlight":   Highlight,
		"add":         func(a, b interface{}) (interface{}, error) { return doArithmetic(a, b, '+') },
		"sub":         func(a, b interface{}) (interface{}, error) { return doArithmetic(a, b, '-') },
		"div":         func(a, b interface{}) (interface{}, error) { return doArithmetic(a, b, '/') },
		"mod":         Mod,
		"mul":         func(a, b interface{}) (interface{}, error) { return doArithmetic(a, b, '*') },
		"modBool":     ModBool,
		"lower":       func(a string) string { return strings.ToLower(a) },
		"upper":       func(a string) string { return strings.ToUpper(a) },
		"title":       func(a string) string { return strings.Title(a) },
		"partial":     Partial,
		"ref":         Ref,
		"relref":      RelRef,
		"apply":       Apply,
		"chomp":       Chomp,
		"replace":     Replace,
		"trim":        Trim,
		"dateFormat":  DateFormat,
		"getJSON":     GetJSON,
		"getCSV":      GetCSV,
		"readDir":     ReadDir,
		"seq":         helpers.Seq,
		"getenv":      func(varName string) string { return os.Getenv(varName) },
	}

}
Ejemplo n.º 2
0
func init() {
	funcMap = template.FuncMap{
		"absURL":       func(a string) template.HTML { return template.HTML(helpers.AbsURL(a)) },
		"add":          func(a, b interface{}) (interface{}, error) { return helpers.DoArithmetic(a, b, '+') },
		"after":        after,
		"apply":        apply,
		"base64Decode": base64Decode,
		"base64Encode": base64Encode,
		"chomp":        chomp,
		"countrunes":   countRunes,
		"countwords":   countWords,
		"default":      dfault,
		"dateFormat":   dateFormat,
		"delimit":      delimit,
		"dict":         dictionary,
		"div":          func(a, b interface{}) (interface{}, error) { return helpers.DoArithmetic(a, b, '/') },
		"echoParam":    returnWhenSet,
		"emojify":      emojify,
		"eq":           eq,
		"findRE":       findRE,
		"first":        first,
		"ge":           ge,
		"getCSV":       getCSV,
		"getJSON":      getJSON,
		"getenv":       func(varName string) string { return os.Getenv(varName) },
		"gt":           gt,
		"hasPrefix":    func(a, b string) bool { return strings.HasPrefix(a, b) },
		"highlight":    highlight,
		"humanize":     humanize,
		"in":           in,
		"index":        index,
		"int":          func(v interface{}) int { return cast.ToInt(v) },
		"intersect":    intersect,
		"isSet":        isSet,
		"isset":        isSet,
		"jsonify":      jsonify,
		"last":         last,
		"le":           le,
		"lower":        func(a string) string { return strings.ToLower(a) },
		"lt":           lt,
		"markdownify":  markdownify,
		"md5":          md5,
		"mod":          mod,
		"modBool":      modBool,
		"mul":          func(a, b interface{}) (interface{}, error) { return helpers.DoArithmetic(a, b, '*') },
		"ne":           ne,
		"partial":      partial,
		"plainify":     plainify,
		"pluralize":    pluralize,
		"querify":      querify,
		"readDir":      readDirFromWorkingDir,
		"readFile":     readFileFromWorkingDir,
		"ref":          ref,
		"relURL":       func(a string) template.HTML { return template.HTML(helpers.RelURL(a)) },
		"relref":       relRef,
		"replace":      replace,
		"replaceRE":    replaceRE,
		"safeCSS":      safeCSS,
		"safeHTML":     safeHTML,
		"safeHTMLAttr": safeHTMLAttr,
		"safeJS":       safeJS,
		"safeURL":      safeURL,
		"sanitizeURL":  helpers.SanitizeURL,
		"sanitizeurl":  helpers.SanitizeURL,
		"seq":          helpers.Seq,
		"sha1":         sha1,
		"shuffle":      shuffle,
		"singularize":  singularize,
		"slice":        slice,
		"slicestr":     slicestr,
		"sort":         sortSeq,
		"split":        split,
		"string":       func(v interface{}) string { return cast.ToString(v) },
		"sub":          func(a, b interface{}) (interface{}, error) { return helpers.DoArithmetic(a, b, '-') },
		"substr":       substr,
		"title":        func(a string) string { return strings.Title(a) },
		"trim":         trim,
		"upper":        func(a string) string { return strings.ToUpper(a) },
		"urlize":       helpers.URLize,
		"where":        where,
	}
}
Ejemplo n.º 3
0
func init() {
	funcMap = template.FuncMap{
		"urlize":      helpers.URLize,
		"sanitizeURL": helpers.SanitizeURL,
		"sanitizeurl": helpers.SanitizeURL,
		"eq":          Eq,
		"ne":          Ne,
		"gt":          Gt,
		"ge":          Ge,
		"lt":          Lt,
		"le":          Le,
		"in":          In,
		"slicestr":    Slicestr,
		"substr":      Substr,
		"split":       Split,
		"intersect":   Intersect,
		"isSet":       IsSet,
		"isset":       IsSet,
		"echoParam":   ReturnWhenSet,
		"safeHTML":    SafeHTML,
		"safeCSS":     SafeCSS,
		"safeURL":     SafeURL,
		"absURL":      func(a string) template.HTML { return template.HTML(helpers.AbsURL(a)) },
		"relURL":      func(a string) template.HTML { return template.HTML(helpers.RelURL(a)) },
		"markdownify": Markdownify,
		"first":       First,
		"where":       Where,
		"delimit":     Delimit,
		"sort":        Sort,
		"highlight":   Highlight,
		"add":         func(a, b interface{}) (interface{}, error) { return doArithmetic(a, b, '+') },
		"sub":         func(a, b interface{}) (interface{}, error) { return doArithmetic(a, b, '-') },
		"div":         func(a, b interface{}) (interface{}, error) { return doArithmetic(a, b, '/') },
		"mod":         Mod,
		"mul":         func(a, b interface{}) (interface{}, error) { return doArithmetic(a, b, '*') },
		"modBool":     ModBool,
		"lower":       func(a string) string { return strings.ToLower(a) },
		"upper":       func(a string) string { return strings.ToUpper(a) },
		"title":       func(a string) string { return strings.Title(a) },
		"partial":     Partial,
		"ref":         Ref,
		"relref":      RelRef,
		"apply":       Apply,
		"chomp":       Chomp,
		"replace":     Replace,
		"trim":        Trim,
		"dateFormat":  DateFormat,
		"getJSON":     GetJSON,
		"getCSV":      GetCSV,
		"seq":         helpers.Seq,
		"getenv":      func(varName string) string { return os.Getenv(varName) },

		// "getJson" is deprecated. Will be removed in 0.15.
		"getJson": func(urlParts ...string) interface{} {
			helpers.Deprecated("Template", "getJson", "getJSON")
			return GetJSON(urlParts...)
		},
		// "getJson" is deprecated. Will be removed in 0.15.
		"getCsv": func(sep string, urlParts ...string) [][]string {
			helpers.Deprecated("Template", "getCsv", "getCSV")
			return GetCSV(sep, urlParts...)
		},
		// "safeHtml" is deprecated. Will be removed in 0.15.
		"safeHtml": func(text string) template.HTML {
			helpers.Deprecated("Template", "safeHtml", "safeHTML")
			return SafeHTML(text)
		},
		// "safeCss" is deprecated. Will be removed in 0.15.
		"safeCss": func(text string) template.CSS {
			helpers.Deprecated("Template", "safeCss", "safeCSS")
			return SafeCSS(text)
		},
		// "safeUrl" is deprecated. Will be removed in 0.15.
		"safeUrl": func(text string) template.URL {
			helpers.Deprecated("Template", "safeUrl", "safeURL")
			return SafeURL(text)
		},
	}

}
Ejemplo n.º 4
0
func init() {
	funcMap = template.FuncMap{
		"urlize":       helpers.URLize,
		"sanitizeURL":  helpers.SanitizeURL,
		"sanitizeurl":  helpers.SanitizeURL,
		"eq":           Eq,
		"ne":           Ne,
		"gt":           Gt,
		"ge":           Ge,
		"lt":           Lt,
		"le":           Le,
		"in":           In,
		"slicestr":     Slicestr,
		"substr":       Substr,
		"intersect":    Intersect,
		"isSet":        IsSet,
		"isset":        IsSet,
		"echoParam":    ReturnWhenSet,
		"safeHTML":     SafeHTML,
		"safeCSS":      SafeCSS,
		"safeURL":      SafeURL,
		"absURL":       func(a string) template.HTML { return template.HTML(helpers.AbsURL(a)) },
		"relURL":       func(a string) template.HTML { return template.HTML(helpers.RelURL(a)) },
		"markdownify":  Markdownify,
		"first":        First,
		"last":         Last,
		"after":        After,
		"where":        Where,
		"delimit":      Delimit,
		"sort":         Sort,
		"highlight":    Highlight,
		"add":          func(a, b interface{}) (interface{}, error) { return doArithmetic(a, b, '+') },
		"sub":          func(a, b interface{}) (interface{}, error) { return doArithmetic(a, b, '-') },
		"div":          func(a, b interface{}) (interface{}, error) { return doArithmetic(a, b, '/') },
		"mod":          Mod,
		"mul":          func(a, b interface{}) (interface{}, error) { return doArithmetic(a, b, '*') },
		"math":         Math,
		"modBool":      ModBool,
		"lower":        func(a string) string { return strings.ToLower(a) },
		"upper":        func(a string) string { return strings.ToUpper(a) },
		"title":        func(a string) string { return strings.Title(a) },
		"partial":      Partial,
		"ref":          Ref,
		"relref":       RelRef,
		"apply":        Apply,
		"chomp":        Chomp,
		"replace":      Replace,
		"trim":         Trim,
		"dateFormat":   DateFormat,
		"getJSON":      GetJSON,
		"getCSV":       GetCSV,
		"readDir":      ReadDir,
		"seq":          helpers.Seq,
		"getenv":       func(varName string) string { return os.Getenv(varName) },
		"base64Decode": Base64Decode,
		"base64Encode": Base64Encode,
		"uuid":         func() string { return uuid.New() },
		"uniquify":     Uniquify,
		"log":          Log,
		"pluralize": func(in interface{}) (string, error) {
			word, err := cast.ToStringE(in)
			if err != nil {
				return "", err
			}
			return inflect.Pluralize(word), nil
		},
		"singularize": func(in interface{}) (string, error) {
			word, err := cast.ToStringE(in)
			if err != nil {
				return "", err
			}
			return inflect.Singularize(word), nil
		},
	}
}
Ejemplo n.º 5
0
func init() {
	funcMap = template.FuncMap{
		"absURL":       func(a string) template.HTML { return template.HTML(helpers.AbsURL(a)) },
		"add":          func(a, b interface{}) (interface{}, error) { return doArithmetic(a, b, '+') },
		"after":        After,
		"apply":        Apply,
		"base64Decode": Base64Decode,
		"base64Encode": Base64Encode,
		"chomp":        Chomp,
		"countrunes":   CountRunes,
		"countwords":   CountWords,
		"dateFormat":   DateFormat,
		"delimit":      Delimit,
		"dict":         Dictionary,
		"div":          func(a, b interface{}) (interface{}, error) { return doArithmetic(a, b, '/') },
		"echoParam":    ReturnWhenSet,
		"eq":           Eq,
		"first":        First,
		"ge":           Ge,
		"getCSV":       GetCSV,
		"getJSON":      GetJSON,
		"getenv":       func(varName string) string { return os.Getenv(varName) },
		"gt":           Gt,
		"hasPrefix":    func(a, b string) bool { return strings.HasPrefix(a, b) },
		"highlight":    Highlight,
		"humanize":     Humanize,
		"in":           In,
		"int":          func(v interface{}) int { return cast.ToInt(v) },
		"intersect":    Intersect,
		"isSet":        IsSet,
		"isset":        IsSet,
		"last":         Last,
		"le":           Le,
		"lower":        func(a string) string { return strings.ToLower(a) },
		"lt":           Lt,
		"markdownify":  Markdownify,
		"mod":          Mod,
		"modBool":      ModBool,
		"mul":          func(a, b interface{}) (interface{}, error) { return doArithmetic(a, b, '*') },
		"ne":           Ne,
		"partial":      Partial,
		"pluralize":    Pluralize,
		"readDir":      ReadDir,
		"ref":          Ref,
		"relURL":       func(a string) template.HTML { return template.HTML(helpers.RelURL(a)) },
		"relref":       RelRef,
		"replace":      Replace,
		"safeCSS":      SafeCSS,
		"safeHTML":     SafeHTML,
		"safeJS":       SafeJS,
		"safeURL":      SafeURL,
		"sanitizeURL":  helpers.SanitizeURL,
		"sanitizeurl":  helpers.SanitizeURL,
		"seq":          helpers.Seq,
		"shuffle":      Shuffle,
		"singularize":  Singularize,
		"slicestr":     Slicestr,
		"sort":         Sort,
		"split":        Split,
		"string":       func(v interface{}) string { return cast.ToString(v) },
		"sub":          func(a, b interface{}) (interface{}, error) { return doArithmetic(a, b, '-') },
		"substr":       Substr,
		"title":        func(a string) string { return strings.Title(a) },
		"trim":         Trim,
		"upper":        func(a string) string { return strings.ToUpper(a) },
		"urlize":       helpers.URLize,
		"where":        Where,
	}
}