mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-07 16:04:45 +00:00
parent
29caaddce6
commit
34c87421b8
1 changed files with 12 additions and 1 deletions
|
@ -2075,6 +2075,17 @@ func relURL(a interface{}) (template.HTML, error) {
|
||||||
return template.HTML(helpers.CurrentPathSpec().RelURL(s, false)), nil
|
return template.HTML(helpers.CurrentPathSpec().RelURL(s, false)), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// getenv retrieves the value of the environment variable named by the key.
|
||||||
|
// It returns the value, which will be empty if the variable is not present.
|
||||||
|
func getenv(key interface{}) (string, error) {
|
||||||
|
skey, err := cast.ToStringE(key)
|
||||||
|
if err != nil {
|
||||||
|
return "", nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return os.Getenv(skey), nil
|
||||||
|
}
|
||||||
|
|
||||||
func initFuncMap() {
|
func initFuncMap() {
|
||||||
funcMap = template.FuncMap{
|
funcMap = template.FuncMap{
|
||||||
"absURL": absURL,
|
"absURL": absURL,
|
||||||
|
@ -2106,7 +2117,7 @@ func initFuncMap() {
|
||||||
"ge": ge,
|
"ge": ge,
|
||||||
"getCSV": getCSV,
|
"getCSV": getCSV,
|
||||||
"getJSON": getJSON,
|
"getJSON": getJSON,
|
||||||
"getenv": func(varName string) string { return os.Getenv(varName) },
|
"getenv": getenv,
|
||||||
"gt": gt,
|
"gt": gt,
|
||||||
"hasPrefix": hasPrefix,
|
"hasPrefix": hasPrefix,
|
||||||
"highlight": highlight,
|
"highlight": highlight,
|
||||||
|
|
Loading…
Add table
Reference in a new issue