Reorganize helpers

This commit is contained in:
spf13 2013-12-05 09:29:41 -05:00
parent 10c7cf2942
commit 44d57fdc0c
7 changed files with 11 additions and 11 deletions

View file

@ -11,7 +11,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package template package helpers
import ( import (
"regexp" "regexp"

View file

@ -14,7 +14,7 @@
package hugolib package hugolib
import ( import (
"github.com/spf13/hugo/template" "github.com/spf13/hugo/helpers"
"sort" "sort"
) )
@ -50,7 +50,7 @@ type IndexList map[string]Index
// KeyPrep... Indexes should be case insensitive. Can make it easily conditional later. // KeyPrep... Indexes should be case insensitive. Can make it easily conditional later.
func kp(in string) string { func kp(in string) string {
return template.Urlize(in) return helpers.Urlize(in)
} }
func (i Index) Get(key string) IndexedPages { return i[kp(key)] } func (i Index) Get(key string) IndexedPages { return i[kp(key)] }

View file

@ -18,8 +18,8 @@ import (
"errors" "errors"
"fmt" "fmt"
"github.com/BurntSushi/toml" "github.com/BurntSushi/toml"
"github.com/spf13/hugo/helpers"
"github.com/spf13/hugo/parser" "github.com/spf13/hugo/parser"
helper "github.com/spf13/hugo/template"
"github.com/spf13/hugo/template/bundle" "github.com/spf13/hugo/template/bundle"
"github.com/theplant/blackfriday" "github.com/theplant/blackfriday"
"html/template" "html/template"
@ -366,12 +366,12 @@ func (page *Page) update(f interface{}) error {
case "description": case "description":
page.Description = interfaceToString(v) page.Description = interfaceToString(v)
case "slug": case "slug":
page.Slug = helper.Urlize(interfaceToString(v)) page.Slug = helpers.Urlize(interfaceToString(v))
case "url": case "url":
if url := interfaceToString(v); strings.HasPrefix(url, "http://") || strings.HasPrefix(url, "https://") { if url := interfaceToString(v); strings.HasPrefix(url, "http://") || strings.HasPrefix(url, "https://") {
return fmt.Errorf("Only relative urls are supported, %v provided", url) 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": case "type":
page.contentType = interfaceToString(v) page.contentType = interfaceToString(v)
case "keywords": case "keywords":

View file

@ -6,7 +6,7 @@ import (
"strconv" "strconv"
"strings" "strings"
helper "github.com/spf13/hugo/template" "github.com/spf13/hugo/helpers"
) )
// PathPattern represents a string which builds up a URL from attributes // 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) { func pageToPermalinkTitle(p *Page, _ string) (string, error) {
// Page contains Node which has Title // Page contains Node which has Title
// (also contains UrlPath which has Slug, sometimes) // (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 // if the page has a slug, return the slug, else return the title

View file

@ -17,9 +17,9 @@ import (
"bitbucket.org/pkg/inflect" "bitbucket.org/pkg/inflect"
"bytes" "bytes"
"fmt" "fmt"
"github.com/spf13/hugo/helpers"
"github.com/spf13/hugo/source" "github.com/spf13/hugo/source"
"github.com/spf13/hugo/target" "github.com/spf13/hugo/target"
helpers "github.com/spf13/hugo/template"
"github.com/spf13/hugo/template/bundle" "github.com/spf13/hugo/template/bundle"
"github.com/spf13/hugo/transform" "github.com/spf13/hugo/transform"
"github.com/spf13/nitro" "github.com/spf13/nitro"

View file

@ -2,7 +2,7 @@ package target
import ( import (
"bytes" "bytes"
helpers "github.com/spf13/hugo/template" "github.com/spf13/hugo/helpers"
"html/template" "html/template"
"path" "path"
"strings" "strings"

View file

@ -3,7 +3,7 @@ package bundle
import ( import (
"errors" "errors"
"github.com/eknkc/amber" "github.com/eknkc/amber"
helpers "github.com/spf13/hugo/template" "github.com/spf13/hugo/helpers"
"html/template" "html/template"
"io" "io"
"io/ioutil" "io/ioutil"