mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
tpl: Unexport the rest of the internal template funcs
This commit is contained in:
parent
f6591eca35
commit
3c100cc32c
4 changed files with 16 additions and 16 deletions
|
@ -1,4 +1,4 @@
|
||||||
// Copyright 2015 The Hugo Authors. All rights reserved.
|
// Copyright 2016 The Hugo Authors. All rights reserved.
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
|
@ -89,7 +89,7 @@ func New() Template {
|
||||||
return templates
|
return templates
|
||||||
}
|
}
|
||||||
|
|
||||||
func Partial(name string, context_list ...interface{}) template.HTML {
|
func partial(name string, context_list ...interface{}) template.HTML {
|
||||||
if strings.HasPrefix("partials/", name) {
|
if strings.HasPrefix("partials/", name) {
|
||||||
name = name[8:]
|
name = name[8:]
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@ func Partial(name string, context_list ...interface{}) template.HTML {
|
||||||
return ExecuteTemplateToHTML(context, "partials/"+name, "theme/partials/"+name)
|
return ExecuteTemplateToHTML(context, "partials/"+name, "theme/partials/"+name)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ExecuteTemplate(context interface{}, w io.Writer, layouts ...string) {
|
func executeTemplate(context interface{}, w io.Writer, layouts ...string) {
|
||||||
worked := false
|
worked := false
|
||||||
for _, layout := range layouts {
|
for _, layout := range layouts {
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ func ExecuteTemplate(context interface{}, w io.Writer, layouts ...string) {
|
||||||
func ExecuteTemplateToHTML(context interface{}, layouts ...string) template.HTML {
|
func ExecuteTemplateToHTML(context interface{}, layouts ...string) template.HTML {
|
||||||
b := bp.GetBuffer()
|
b := bp.GetBuffer()
|
||||||
defer bp.PutBuffer(b)
|
defer bp.PutBuffer(b)
|
||||||
ExecuteTemplate(context, b, layouts...)
|
executeTemplate(context, b, layouts...)
|
||||||
return template.HTML(b.String())
|
return template.HTML(b.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1526,8 +1526,8 @@ func init() {
|
||||||
"eq": eq,
|
"eq": eq,
|
||||||
"first": first,
|
"first": first,
|
||||||
"ge": ge,
|
"ge": ge,
|
||||||
"getCSV": GetCSV,
|
"getCSV": getCSV,
|
||||||
"getJSON": GetJSON,
|
"getJSON": getJSON,
|
||||||
"getenv": func(varName string) string { return os.Getenv(varName) },
|
"getenv": func(varName string) string { return os.Getenv(varName) },
|
||||||
"gt": gt,
|
"gt": gt,
|
||||||
"hasPrefix": func(a, b string) bool { return strings.HasPrefix(a, b) },
|
"hasPrefix": func(a, b string) bool { return strings.HasPrefix(a, b) },
|
||||||
|
@ -1547,9 +1547,9 @@ func init() {
|
||||||
"modBool": modBool,
|
"modBool": modBool,
|
||||||
"mul": func(a, b interface{}) (interface{}, error) { return doArithmetic(a, b, '*') },
|
"mul": func(a, b interface{}) (interface{}, error) { return doArithmetic(a, b, '*') },
|
||||||
"ne": ne,
|
"ne": ne,
|
||||||
"partial": Partial,
|
"partial": partial,
|
||||||
"pluralize": pluralize,
|
"pluralize": pluralize,
|
||||||
"readDir": ReadDir,
|
"readDir": readDir,
|
||||||
"ref": ref,
|
"ref": ref,
|
||||||
"relURL": func(a string) template.HTML { return template.HTML(helpers.RelURL(a)) },
|
"relURL": func(a string) template.HTML { return template.HTML(helpers.RelURL(a)) },
|
||||||
"relref": relRef,
|
"relref": relRef,
|
||||||
|
|
|
@ -182,10 +182,10 @@ func resGetResource(url string) ([]byte, error) {
|
||||||
return resGetLocal(url, hugofs.SourceFs)
|
return resGetLocal(url, hugofs.SourceFs)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetJSON expects one or n-parts of a URL to a resource which can either be a local or a remote one.
|
// getJSON expects one or n-parts of a URL to a resource which can either be a local or a remote one.
|
||||||
// If you provide multiple parts they will be joined together to the final URL.
|
// If you provide multiple parts they will be joined together to the final URL.
|
||||||
// GetJSON returns nil or parsed JSON to use in a short code.
|
// GetJSON returns nil or parsed JSON to use in a short code.
|
||||||
func GetJSON(urlParts ...string) interface{} {
|
func getJSON(urlParts ...string) interface{} {
|
||||||
var v interface{}
|
var v interface{}
|
||||||
url := strings.Join(urlParts, "")
|
url := strings.Join(urlParts, "")
|
||||||
|
|
||||||
|
@ -222,12 +222,12 @@ func parseCSV(c []byte, sep string) ([][]string, error) {
|
||||||
return r.ReadAll()
|
return r.ReadAll()
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetCSV expects a data separator and one or n-parts of a URL to a resource which
|
// getCSV expects a data separator and one or n-parts of a URL to a resource which
|
||||||
// can either be a local or a remote one.
|
// can either be a local or a remote one.
|
||||||
// The data separator can be a comma, semi-colon, pipe, etc, but only one character.
|
// The data separator can be a comma, semi-colon, pipe, etc, but only one character.
|
||||||
// If you provide multiple parts for the URL they will be joined together to the final URL.
|
// If you provide multiple parts for the URL they will be joined together to the final URL.
|
||||||
// GetCSV returns nil or a slice slice to use in a short code.
|
// GetCSV returns nil or a slice slice to use in a short code.
|
||||||
func GetCSV(sep string, urlParts ...string) [][]string {
|
func getCSV(sep string, urlParts ...string) [][]string {
|
||||||
var d [][]string
|
var d [][]string
|
||||||
url := strings.Join(urlParts, "")
|
url := strings.Join(urlParts, "")
|
||||||
|
|
||||||
|
@ -260,7 +260,7 @@ func GetCSV(sep string, urlParts ...string) [][]string {
|
||||||
return d
|
return d
|
||||||
}
|
}
|
||||||
|
|
||||||
func ReadDir(path string) []os.FileInfo {
|
func readDir(path string) []os.FileInfo {
|
||||||
wd := ""
|
wd := ""
|
||||||
p := ""
|
p := ""
|
||||||
if viper.GetString("WorkingDir") != "" {
|
if viper.GetString("WorkingDir") != "" {
|
||||||
|
|
|
@ -242,7 +242,7 @@ func TestGetJSONFailParse(t *testing.T) {
|
||||||
defer os.Remove(getCacheFileID(url))
|
defer os.Remove(getCacheFileID(url))
|
||||||
|
|
||||||
want := map[string]interface{}{"gomeetup": []interface{}{"Sydney", "San Francisco", "Stockholm"}}
|
want := map[string]interface{}{"gomeetup": []interface{}{"Sydney", "San Francisco", "Stockholm"}}
|
||||||
have := GetJSON(url)
|
have := getJSON(url)
|
||||||
assert.NotNil(t, have)
|
assert.NotNil(t, have)
|
||||||
if have != nil {
|
if have != nil {
|
||||||
assert.EqualValues(t, want, have)
|
assert.EqualValues(t, want, have)
|
||||||
|
@ -271,7 +271,7 @@ func TestGetCSVFailParseSep(t *testing.T) {
|
||||||
defer os.Remove(getCacheFileID(url))
|
defer os.Remove(getCacheFileID(url))
|
||||||
|
|
||||||
want := [][]string{{"gomeetup", "city"}, {"yes", "Sydney"}, {"yes", "San Francisco"}, {"yes", "Stockholm"}}
|
want := [][]string{{"gomeetup", "city"}, {"yes", "Sydney"}, {"yes", "San Francisco"}, {"yes", "Stockholm"}}
|
||||||
have := GetCSV(",", url)
|
have := getCSV(",", url)
|
||||||
assert.NotNil(t, have)
|
assert.NotNil(t, have)
|
||||||
if have != nil {
|
if have != nil {
|
||||||
assert.EqualValues(t, want, have)
|
assert.EqualValues(t, want, have)
|
||||||
|
@ -302,7 +302,7 @@ func TestGetCSVFailParse(t *testing.T) {
|
||||||
defer os.Remove(getCacheFileID(url))
|
defer os.Remove(getCacheFileID(url))
|
||||||
|
|
||||||
want := [][]string{{"gomeetup", "city"}, {"yes", "Sydney"}, {"yes", "San Francisco"}, {"yes", "Stockholm"}}
|
want := [][]string{{"gomeetup", "city"}, {"yes", "Sydney"}, {"yes", "San Francisco"}, {"yes", "Stockholm"}}
|
||||||
have := GetCSV(",", url)
|
have := getCSV(",", url)
|
||||||
assert.NotNil(t, have)
|
assert.NotNil(t, have)
|
||||||
if have != nil {
|
if have != nil {
|
||||||
assert.EqualValues(t, want, have)
|
assert.EqualValues(t, want, have)
|
||||||
|
|
Loading…
Reference in a new issue