tpl/urls: Make it a package that stands on its own

See #3042
This commit is contained in:
Bjørn Erik Pedersen
2017-04-30 23:33:14 +02:00
parent 55f90a3a0d
commit 4714085a10
4 changed files with 60 additions and 31 deletions

View File

@@ -38,6 +38,7 @@ import (
_ "github.com/spf13/hugo/tpl/strings"
_ "github.com/spf13/hugo/tpl/time"
_ "github.com/spf13/hugo/tpl/transform"
_ "github.com/spf13/hugo/tpl/urls"
)
// Get retrieves partial output from the cache based upon the partial name.
@@ -92,20 +93,12 @@ func (t *templateFuncster) initFuncMap() {
funcMap := template.FuncMap{
// Namespaces
//"time": t.time.Namespace,
"urls": t.urls.Namespace,
"absURL": t.urls.AbsURL,
"absLangURL": t.urls.AbsLangURL,
"int": func(v interface{}) (int, error) { return cast.ToIntE(v) },
"partial": t.partial,
"partialCached": t.partialCached,
"print": fmt.Sprint,
"printf": fmt.Sprintf,
"println": fmt.Sprintln,
"ref": t.urls.Ref,
"relURL": t.urls.RelURL,
"relLangURL": t.urls.RelLangURL,
"relref": t.urls.RelRef,
"string": func(v interface{}) (string, error) { return cast.ToStringE(v) },
"urlize": t.PathSpec.URLize,
}