hugo/transform/absurl.go
Anthony Fok 67df33f500 Correct initialisms as suggested by golint
First step to use initialisms that golint suggests,
for example:

    Line 116: func GetHtmlRenderer should be GetHTMLRenderer

as see on http://goreportcard.com/report/spf13/hugo

Thanks to @bep for the idea!

Note that command-line flags (cobra and pflag)
as well as struct fields like .BaseUrl and .Url
that are used in Go HTML templates need more work
to maintain backward-compatibility, and thus
are NOT yet dealt with in this commit.

First step in fixing #959.
2015-03-11 21:55:00 +01:00

34 lines
621 B
Go

package transform
import (
"sync"
)
var absURLInit sync.Once
var ar *absURLReplacer
// for performance reasons, we reuse the first baseUrl given
func initAbsurlReplacer(baseURL string) {
absURLInit.Do(func() {
ar = newAbsurlReplacer(baseURL)
})
}
func AbsURL(absURL string) (trs []link, err error) {
initAbsurlReplacer(absURL)
trs = append(trs, func(content []byte) []byte {
return ar.replaceInHTML(content)
})
return
}
func AbsURLInXML(absURL string) (trs []link, err error) {
initAbsurlReplacer(absURL)
trs = append(trs, func(content []byte) []byte {
return ar.replaceInXML(content)
})
return
}