mirror of
https://github.com/gohugoio/hugo.git
synced 2025-01-24 05:41:36 +00: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");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
@ -89,7 +89,7 @@ func New() Template {
|
|||
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) {
|
||||
name = name[8:]
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ func Partial(name string, context_list ...interface{}) template.HTML {
|
|||
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
|
||||
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 {
|
||||
b := bp.GetBuffer()
|
||||
defer bp.PutBuffer(b)
|
||||
ExecuteTemplate(context, b, layouts...)
|
||||
executeTemplate(context, b, layouts...)
|
||||
return template.HTML(b.String())
|
||||
}
|
||||
|
||||
|
|
|
@ -1526,8 +1526,8 @@ func init() {
|
|||
"eq": eq,
|
||||
"first": first,
|
||||
"ge": ge,
|
||||
"getCSV": GetCSV,
|
||||
"getJSON": GetJSON,
|
||||
"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) },
|
||||
|
@ -1547,9 +1547,9 @@ func init() {
|
|||
"modBool": modBool,
|
||||
"mul": func(a, b interface{}) (interface{}, error) { return doArithmetic(a, b, '*') },
|
||||
"ne": ne,
|
||||
"partial": Partial,
|
||||
"partial": partial,
|
||||
"pluralize": pluralize,
|
||||
"readDir": ReadDir,
|
||||
"readDir": readDir,
|
||||
"ref": ref,
|
||||
"relURL": func(a string) template.HTML { return template.HTML(helpers.RelURL(a)) },
|
||||
"relref": relRef,
|
||||
|
|
|
@ -182,10 +182,10 @@ func resGetResource(url string) ([]byte, error) {
|
|||
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.
|
||||
// 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{}
|
||||
url := strings.Join(urlParts, "")
|
||||
|
||||
|
@ -222,12 +222,12 @@ func parseCSV(c []byte, sep string) ([][]string, error) {
|
|||
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.
|
||||
// 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.
|
||||
// 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
|
||||
url := strings.Join(urlParts, "")
|
||||
|
||||
|
@ -260,7 +260,7 @@ func GetCSV(sep string, urlParts ...string) [][]string {
|
|||
return d
|
||||
}
|
||||
|
||||
func ReadDir(path string) []os.FileInfo {
|
||||
func readDir(path string) []os.FileInfo {
|
||||
wd := ""
|
||||
p := ""
|
||||
if viper.GetString("WorkingDir") != "" {
|
||||
|
|
|
@ -242,7 +242,7 @@ func TestGetJSONFailParse(t *testing.T) {
|
|||
defer os.Remove(getCacheFileID(url))
|
||||
|
||||
want := map[string]interface{}{"gomeetup": []interface{}{"Sydney", "San Francisco", "Stockholm"}}
|
||||
have := GetJSON(url)
|
||||
have := getJSON(url)
|
||||
assert.NotNil(t, have)
|
||||
if have != nil {
|
||||
assert.EqualValues(t, want, have)
|
||||
|
@ -271,7 +271,7 @@ func TestGetCSVFailParseSep(t *testing.T) {
|
|||
defer os.Remove(getCacheFileID(url))
|
||||
|
||||
want := [][]string{{"gomeetup", "city"}, {"yes", "Sydney"}, {"yes", "San Francisco"}, {"yes", "Stockholm"}}
|
||||
have := GetCSV(",", url)
|
||||
have := getCSV(",", url)
|
||||
assert.NotNil(t, have)
|
||||
if have != nil {
|
||||
assert.EqualValues(t, want, have)
|
||||
|
@ -302,7 +302,7 @@ func TestGetCSVFailParse(t *testing.T) {
|
|||
defer os.Remove(getCacheFileID(url))
|
||||
|
||||
want := [][]string{{"gomeetup", "city"}, {"yes", "Sydney"}, {"yes", "San Francisco"}, {"yes", "Stockholm"}}
|
||||
have := GetCSV(",", url)
|
||||
have := getCSV(",", url)
|
||||
assert.NotNil(t, have)
|
||||
if have != nil {
|
||||
assert.EqualValues(t, want, have)
|
||||
|
|
Loading…
Reference in a new issue