shithub: hugo

Download patch

ref: 3c100cc32c49c80a2b45020b4305360782bf2a4c
parent: f6591eca35e0051873ea348a073522bd1b73b743
author: Bjørn Erik Pedersen <[email protected]>
date: Thu Mar 3 20:00:41 EST 2016

tpl: Unexport the rest of the internal template funcs

--- a/tpl/template.go
+++ b/tpl/template.go
@@ -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 @@
 	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 @@
 	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 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())
 }
 
--- a/tpl/template_funcs.go
+++ b/tpl/template_funcs.go
@@ -1526,8 +1526,8 @@
 		"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 @@
 		"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,
--- a/tpl/template_resources.go
+++ b/tpl/template_resources.go
@@ -182,10 +182,10 @@
 	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 @@
 	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 @@
 	return d
 }
 
-func ReadDir(path string) []os.FileInfo {
+func readDir(path string) []os.FileInfo {
 	wd := ""
 	p := ""
 	if viper.GetString("WorkingDir") != "" {
--- a/tpl/template_resources_test.go
+++ b/tpl/template_resources_test.go
@@ -242,7 +242,7 @@
 	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 @@
 	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 @@
 	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)