hugo/transform/chain.go
Noah Campbell 86233c00a0 Remove the hugo-nav function
Remove the hugo-nav since it relied on a slow library.  The current
build reimplements the absurl functionality based on string replace.
Discovered that my prior implementation missed the requirement for
making absolute paths (/path) absolute with the host, whereas a relative
path is left untouched.  Updated the test cases to support this if this
is reimplemented.
2013-11-05 22:28:06 +00:00

31 lines
399 B
Go

package transform
import (
"bytes"
"io"
)
type trans func([]byte) []byte
type link trans
type chain []link
func NewChain(trs ...link) chain {
return trs
}
func (c *chain) Apply(w io.Writer, r io.Reader) (err error) {
buffer := new(bytes.Buffer)
buffer.ReadFrom(r)
b := buffer.Bytes()
for _, tr := range *c {
b = tr(b)
}
buffer.Reset()
buffer.Write(b)
buffer.WriteTo(w)
return
}