diff --git a/go.mod b/go.mod index 73e4c0cac0..86edde20f9 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/fsnotify/fsnotify v1.7.0 github.com/matryer/try v0.0.0-20161228173917-9ac251b645a2 github.com/tdewolff/argp v0.0.0-20231030173501-fa6c54897951 - github.com/tdewolff/parse/v2 v2.7.3-0.20231031130755-de6a78ee073c + github.com/tdewolff/parse/v2 v2.7.3-0.20231031132452-e7c20a5d77ab github.com/tdewolff/test v1.0.10 ) diff --git a/go.sum b/go.sum index fc6c87b808..93e5d18d98 100644 --- a/go.sum +++ b/go.sum @@ -12,6 +12,10 @@ github.com/tdewolff/argp v0.0.0-20231030173501-fa6c54897951 h1:QiakK8TMHgZfKZ2en github.com/tdewolff/argp v0.0.0-20231030173501-fa6c54897951/go.mod h1:fF+gnKbmf3iMG+ErLiF+orMU/InyZIEnKVVigUjfriw= github.com/tdewolff/parse/v2 v2.7.2 h1:9NdxF0nk/+lPI0YADDonSlpiY15hGcVUhXRj9hnK8sM= github.com/tdewolff/parse/v2 v2.7.2/go.mod h1:9p2qMIHpjRSTr1qnFxQr+igogyTUTlwvf9awHSm84h8= +github.com/tdewolff/parse/v2 v2.7.3-0.20231031130755-de6a78ee073c h1:i84Tgo9fHJFtEEZ+8qJDhbA5TPInhd6aMLZIui72ivc= +github.com/tdewolff/parse/v2 v2.7.3-0.20231031130755-de6a78ee073c/go.mod h1:9p2qMIHpjRSTr1qnFxQr+igogyTUTlwvf9awHSm84h8= +github.com/tdewolff/parse/v2 v2.7.3-0.20231031132452-e7c20a5d77ab h1:4zj+h84OrVW4pljmp+LABknN7VS1IMAbeHj+eckO6Ao= +github.com/tdewolff/parse/v2 v2.7.3-0.20231031132452-e7c20a5d77ab/go.mod h1:9p2qMIHpjRSTr1qnFxQr+igogyTUTlwvf9awHSm84h8= github.com/tdewolff/test v1.0.6/go.mod h1:6DAvZliBAAnD7rhVgwaM7DE5/d9NMOAJ09SqYqeK4QE= github.com/tdewolff/test v1.0.10 h1:uWiheaLgLcNFqHcdWveum7PQfMnIUTf9Kl3bFxrIoew= github.com/tdewolff/test v1.0.10/go.mod h1:6DAvZliBAAnD7rhVgwaM7DE5/d9NMOAJ09SqYqeK4QE= diff --git a/html/html.go b/html/html.go index b31d67bd87..9a7b55bdd1 100644 --- a/html/html.go +++ b/html/html.go @@ -134,7 +134,6 @@ func (o *Minifier) Minify(m *minify.M, w io.Writer, r io.Reader, _ map[string]st w.Write(t.Data) } case html.TextToken: - // CSS and JS minifiers for inline code if t.HasTemplate { w.Write(t.Data) } else if rawTagHash != 0 { diff --git a/html/html_test.go b/html/html_test.go index e3dcebf017..3388a6de75 100644 --- a/html/html_test.go +++ b/html/html_test.go @@ -364,11 +364,17 @@ func TestHTMLTemplates(t *testing.T) { {`a {{ printf " ! " }} b`, `a {{ printf " ! " }} b`}, {``, ``}, {``, ``}, - {`Foo`, `Foo`}, + {`Foo`, `Foo`}, + {``, ``}, + {``, ``}, + {``, ``}, + {``, ``}, } m := minify.New() - htmlMinifier := &Minifier{KeepEndTags: true, TemplateDelims: GoTemplateDelims} + m.AddFunc("text/css", css.Minify) + m.AddFunc("application/javascript", js.Minify) + htmlMinifier := &Minifier{TemplateDelims: GoTemplateDelims} for _, tt := range htmlTests { t.Run(tt.html, func(t *testing.T) { r := bytes.NewBufferString(tt.html)