hugo/transform/chain.go
Phil Pennock 438c219892 Add canonifyurls config option.
Be able to inhibit AbsURL canonicalization of content, on a site
configuration basis. Advantages of being able to inhibit this include
making it easier to rendering on other hostnames, and being able to
include resources on http or https depending on how this page was
retrieved, avoiding mixed-mode client complaints without adding latency
for plain http.
2014-01-13 10:06:12 -05:00

35 lines
465 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 NewEmptyTransforms() []link {
return make([]link, 0, 20)
}
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
}