From 44d57fdc0ce6743a92a8ad8b73566e344762cc24 Mon Sep 17 00:00:00 2001 From: spf13 Date: Thu, 5 Dec 2013 09:29:41 -0500 Subject: [PATCH] Reorganize helpers --- template/helpers.go => helpers/templates.go | 2 +- hugolib/index.go | 4 ++-- hugolib/page.go | 6 +++--- hugolib/permalinks.go | 4 ++-- hugolib/site.go | 2 +- target/htmlredirect.go | 2 +- template/bundle/template.go | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) rename template/helpers.go => helpers/templates.go (98%) diff --git a/template/helpers.go b/helpers/templates.go similarity index 98% rename from template/helpers.go rename to helpers/templates.go index d12ffd96c..793450b43 100644 --- a/template/helpers.go +++ b/helpers/templates.go @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package template +package helpers import ( "regexp" diff --git a/hugolib/index.go b/hugolib/index.go index c3396b286..38441d463 100644 --- a/hugolib/index.go +++ b/hugolib/index.go @@ -14,7 +14,7 @@ package hugolib import ( - "github.com/spf13/hugo/template" + "github.com/spf13/hugo/helpers" "sort" ) @@ -50,7 +50,7 @@ type IndexList map[string]Index // KeyPrep... Indexes should be case insensitive. Can make it easily conditional later. func kp(in string) string { - return template.Urlize(in) + return helpers.Urlize(in) } func (i Index) Get(key string) IndexedPages { return i[kp(key)] } diff --git a/hugolib/page.go b/hugolib/page.go index 101f6c884..d9f4ad6ca 100644 --- a/hugolib/page.go +++ b/hugolib/page.go @@ -18,8 +18,8 @@ import ( "errors" "fmt" "github.com/BurntSushi/toml" + "github.com/spf13/hugo/helpers" "github.com/spf13/hugo/parser" - helper "github.com/spf13/hugo/template" "github.com/spf13/hugo/template/bundle" "github.com/theplant/blackfriday" "html/template" @@ -366,12 +366,12 @@ func (page *Page) update(f interface{}) error { case "description": page.Description = interfaceToString(v) case "slug": - page.Slug = helper.Urlize(interfaceToString(v)) + page.Slug = helpers.Urlize(interfaceToString(v)) case "url": if url := interfaceToString(v); strings.HasPrefix(url, "http://") || strings.HasPrefix(url, "https://") { return fmt.Errorf("Only relative urls are supported, %v provided", url) } - page.Url = helper.Urlize(interfaceToString(v)) + page.Url = helpers.Urlize(interfaceToString(v)) case "type": page.contentType = interfaceToString(v) case "keywords": diff --git a/hugolib/permalinks.go b/hugolib/permalinks.go index 41e797ea3..155b1b813 100644 --- a/hugolib/permalinks.go +++ b/hugolib/permalinks.go @@ -6,7 +6,7 @@ import ( "strconv" "strings" - helper "github.com/spf13/hugo/template" + "github.com/spf13/hugo/helpers" ) // PathPattern represents a string which builds up a URL from attributes @@ -117,7 +117,7 @@ func pageToPermalinkDate(p *Page, dateField string) (string, error) { func pageToPermalinkTitle(p *Page, _ string) (string, error) { // Page contains Node which has Title // (also contains UrlPath which has Slug, sometimes) - return helper.Urlize(p.Title), nil + return helpers.Urlize(p.Title), nil } // if the page has a slug, return the slug, else return the title diff --git a/hugolib/site.go b/hugolib/site.go index 128b23962..75ba6bfa8 100644 --- a/hugolib/site.go +++ b/hugolib/site.go @@ -17,9 +17,9 @@ import ( "bitbucket.org/pkg/inflect" "bytes" "fmt" + "github.com/spf13/hugo/helpers" "github.com/spf13/hugo/source" "github.com/spf13/hugo/target" - helpers "github.com/spf13/hugo/template" "github.com/spf13/hugo/template/bundle" "github.com/spf13/hugo/transform" "github.com/spf13/nitro" diff --git a/target/htmlredirect.go b/target/htmlredirect.go index a2695c6d9..53e900f91 100644 --- a/target/htmlredirect.go +++ b/target/htmlredirect.go @@ -2,7 +2,7 @@ package target import ( "bytes" - helpers "github.com/spf13/hugo/template" + "github.com/spf13/hugo/helpers" "html/template" "path" "strings" diff --git a/template/bundle/template.go b/template/bundle/template.go index 879bd1491..a53b38fad 100644 --- a/template/bundle/template.go +++ b/template/bundle/template.go @@ -3,7 +3,7 @@ package bundle import ( "errors" "github.com/eknkc/amber" - helpers "github.com/spf13/hugo/template" + "github.com/spf13/hugo/helpers" "html/template" "io" "io/ioutil"