Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tpl
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2016-09-13 18:07:52 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2016-09-13 18:07:52 +0300
commita04abf0ddaed444ae87e6f22a3430e309e5db919 (patch)
treed0cb05c3de79f11d4ca278608240926f3d5a0119 /tpl
parent7615ef0c2866d3068b131b9d6f80f8d432d54e13 (diff)
tpl: Make the *langURL funcs tace interface{}
Fixes #2447
Diffstat (limited to 'tpl')
-rw-r--r--tpl/template_funcs.go18
1 files changed, 15 insertions, 3 deletions
diff --git a/tpl/template_funcs.go b/tpl/template_funcs.go
index c82b6fae8..099f9d74e 100644
--- a/tpl/template_funcs.go
+++ b/tpl/template_funcs.go
@@ -1907,8 +1907,14 @@ func relURL(a interface{}) (template.HTML, error) {
func init() {
funcMap = template.FuncMap{
- "absURL": absURL,
- "absLangURL": func(a string) template.HTML { return template.HTML(helpers.AbsURL(a, true)) },
+ "absURL": absURL,
+ "absLangURL": func(i interface{}) (template.HTML, error) {
+ s, err := cast.ToStringE(i)
+ if err != nil {
+ return "", err
+ }
+ return template.HTML(helpers.AbsURL(s, true)), nil
+ },
"add": func(a, b interface{}) (interface{}, error) { return helpers.DoArithmetic(a, b, '+') },
"after": after,
"apply": apply,
@@ -1962,7 +1968,13 @@ func init() {
"readFile": readFileFromWorkingDir,
"ref": ref,
"relURL": relURL,
- "relLangURL": func(a string) template.HTML { return template.HTML(helpers.RelURL(a, true)) },
+ "relLangURL": func(i interface{}) (template.HTML, error) {
+ s, err := cast.ToStringE(i)
+ if err != nil {
+ return "", err
+ }
+ return template.HTML(helpers.RelURL(s, true)), nil
+ },
"relref": relRef,
"replace": replace,
"replaceRE": replaceRE,