From 1d18eb0574a57c3e9f468659d076a666a3dd76f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Thu, 1 Nov 2018 11:28:30 +0100 Subject: Add file (line/col) info to ref/relref errors See #5371 --- tpl/urls/urls.go | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'tpl/urls/urls.go') diff --git a/tpl/urls/urls.go b/tpl/urls/urls.go index 8f6f92f3d..7abf45ba2 100644 --- a/tpl/urls/urls.go +++ b/tpl/urls/urls.go @@ -20,10 +20,10 @@ import ( "html/template" "net/url" + "github.com/gohugoio/hugo/common/urls" + "github.com/gohugoio/hugo/deps" _errors "github.com/pkg/errors" "github.com/russross/blackfriday" - - "github.com/gohugoio/hugo/deps" "github.com/spf13/cast" ) @@ -91,14 +91,9 @@ func (ns *Namespace) Anchorize(a interface{}) (string, error) { return blackfriday.SanitizedAnchorName(s), nil } -type reflinker interface { - Ref(args map[string]interface{}) (string, error) - RelRef(args map[string]interface{}) (string, error) -} - // Ref returns the absolute URL path to a given content item. func (ns *Namespace) Ref(in interface{}, args interface{}) (template.HTML, error) { - p, ok := in.(reflinker) + p, ok := in.(urls.RefLinker) if !ok { return "", errors.New("invalid Page received in Ref") } @@ -112,7 +107,7 @@ func (ns *Namespace) Ref(in interface{}, args interface{}) (template.HTML, error // RelRef returns the relative URL path to a given content item. func (ns *Namespace) RelRef(in interface{}, args interface{}) (template.HTML, error) { - p, ok := in.(reflinker) + p, ok := in.(urls.RefLinker) if !ok { return "", errors.New("invalid Page received in RelRef") } -- cgit v1.2.3