hugo/transform/absurl.go
Anthony Fok 8b8fb417ae More initialism corrections (golint)
Thanks to @bep's new, brilliant helpers.Deprecated() function,
the following functions or variables are transitioned to their
new names, preserving backward compatibility for v0.14
and warning the user of upcoming obsolescence in v0.15:

 * .Url → .URL (for node, menu and paginator)
 * .Site.BaseUrl → .Site.BaseURL
 * .Site.Indexes → .Site.Taxonomies
 * .Site.Recent → .Site.Pages
 * getJson → getJSON
 * getCsv → getCSV
 * safeHtml → safeHTML
 * safeCss → safeCSS
 * safeUrl → safeURL

Also fix related initialisms in strings and comments.

Continued effort in fixing #959.
2015-03-18 11:30:37 +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
}