Rename interface contentRewriter to contentTransformer

Is is a much better name.
This commit is contained in:
bep 2015-03-19 01:55:49 +01:00
parent efb564775a
commit 66cf3bdc77
5 changed files with 26 additions and 26 deletions

View file

@ -5,19 +5,19 @@ import (
"github.com/spf13/viper"
)
func LiveReloadInject(rw contentRewriter) {
func LiveReloadInject(ct contentTransformer) {
match := []byte("</body>")
port := viper.GetString("port")
replace := []byte(`<script>document.write('<script src="http://'
+ (location.host || 'localhost').split(':')[0]
+ ':` + port + `/livereload.js?mindelay=10"></'
+ 'script>')</script></body>`)
newcontent := bytes.Replace(rw.Content(), match, replace, -1)
newcontent := bytes.Replace(ct.Content(), match, replace, -1)
if len(newcontent) == len(rw.Content()) {
if len(newcontent) == len(ct.Content()) {
match := []byte("</BODY>")
newcontent = bytes.Replace(rw.Content(), match, replace, -1)
newcontent = bytes.Replace(ct.Content(), match, replace, -1)
}
rw.Write(newcontent)
ct.Write(newcontent)
}