Skip to content
This repository has been archived by the owner on Nov 10, 2017. It is now read-only.

Commit

Permalink
tpl: Unexport the rest of the internal template funcs
Browse files Browse the repository at this point in the history
  • Loading branch information
bep committed Mar 4, 2016
1 parent f6591ec commit 3c100cc
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions tpl/template.go
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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:]
}
Expand All @@ -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 {

Expand Down Expand Up @@ -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())
}

Expand Down
8 changes: 4 additions & 4 deletions tpl/template_funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) },
Expand All @@ -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,
Expand Down
10 changes: 5 additions & 5 deletions tpl/template_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, "")

Expand Down Expand Up @@ -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, "")

Expand Down Expand Up @@ -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") != "" {
Expand Down
6 changes: 3 additions & 3 deletions tpl/template_resources_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 3c100cc

Please sign in to comment.