toolchain go1.21.0
-go 1.20
+go 1.21
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-//go:build go1.13 && !windows
-// +build go1.13,!windows
+//go:build !windows
+// +build !windows
package template
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-//go:build go1.13 && !windows
-// +build go1.13,!windows
+//go:build !windows
+// +build !windows
package template
if err := tmpl.Execute(b, s); err != nil {
t.Fatal(err)
}
- var expect = "string=3"
+ expect := "string=3"
if b.String() != expect {
t.Errorf("expected %q got %q", expect, b.String())
}
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-//go:build go1.13 && !windows
-// +build go1.13,!windows
+//go:build !windows
+// +build !windows
package template
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-//go:build go1.13 && !windows
-// +build go1.13,!windows
+//go:build !windows
+// +build !windows
package template
t.Errorf("want\n\t%q\ngot\n\t%q", test.want, got)
}
}
-
}
func TestErrors(t *testing.T) {
// Check that we get the same error if we call Execute again.
if err := tmpl.Execute(buf, nil); err == nil || err.Error() != got {
t.Errorf("input=%q: unexpected error on second call %q", test.input, err)
-
}
}
}
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-//go:build go1.13
-// +build go1.13
-
package template_test
import (
// <div><strong>no rows</strong></div>
// </body>
// </html>
-
}
func Example_autoescaping() {
// \"Fran \u0026 Freddie\'s Diner\" \u003Ctasty@example.com\u003E
// \"Fran \u0026 Freddie\'s Diner\"32\u003Ctasty@example.com\u003E
// %22Fran+%26+Freddie%27s+Diner%2232%3Ctasty%40example.com%3E
-
}
func ExampleTemplate_Delims() {
// Tests for template execution, copied from text/template.
-//go:build go1.13 && !windows
-// +build go1.13,!windows
+//go:build !windows
+// +build !windows
package template
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-//go:build go1.13 && !windows
-// +build go1.13,!windows
+//go:build !windows
+// +build !windows
package template
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-//go:build go1.13 && !windows
-// +build go1.13,!windows
+//go:build !windows
+// +build !windows
package template
{"<!--", `\u003c!--`},
{"-->", `--\u003e`},
// From https://code.google.com/p/doctype/wiki/ArticleUtf7
- {"+ADw-script+AD4-alert(1)+ADw-/script+AD4-",
+ {
+ "+ADw-script+AD4-alert(1)+ADw-/script+AD4-",
`\u002bADw-script\u002bAD4-alert(1)\u002bADw-\/script\u002bAD4-`,
},
// Invalid UTF-8 sequence
// Tests for multiple-template execution, copied from text/template.
-//go:build go1.13 && !windows
-// +build go1.13,!windows
+//go:build !windows
+// +build !windows
package template
// by the contents of "stylesheet", but if the internal map associating
// names with templates is built in the wrong order, the empty block
// looks non-empty and this doesn't happen.
- var inlined = map[string]string{
+ inlined := map[string]string{
"stylesheet": `{{define "stylesheet"}}stylesheet{{end}}`,
"xhtml": `{{block "stylesheet" .}}{{end}}`,
}
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-//go:build go1.13
-// +build go1.13
-
package template_test
import (
)
func TestTemplateClone(t *testing.T) {
-
orig := New("name")
clone, err := orig.Clone()
if err != nil {
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-//go:build go1.13 && !windows
-// +build go1.13,!windows
+//go:build !windows
+// +build !windows
package template
}
func BenchmarkTemplateSpecialTags(b *testing.B) {
-
r := struct {
Name, Gift string
}{"Aunt Mildred", "bone china tea set"}
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-//go:build go1.13 && !windows
-// +build go1.13,!windows
+//go:build !windows
+// +build !windows
package template
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-//go:build go1.13 && !windows
-// +build go1.13,!windows
+//go:build !windows
+// +build !windows
package template
import (
"fmt"
- "github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate/parse"
"os"
"strings"
"testing"
+
+ "github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate/parse"
)
const (
}
var multiParseTests = []multiParseTest{
- {"empty", "", noError,
+ {
+ "empty", "", noError,
+ nil,
nil,
- nil},
- {"one", `{{define "foo"}} FOO {{end}}`, noError,
+ },
+ {
+ "one", `{{define "foo"}} FOO {{end}}`, noError,
[]string{"foo"},
- []string{" FOO "}},
- {"two", `{{define "foo"}} FOO {{end}}{{define "bar"}} BAR {{end}}`, noError,
+ []string{" FOO "},
+ },
+ {
+ "two", `{{define "foo"}} FOO {{end}}{{define "bar"}} BAR {{end}}`, noError,
[]string{"foo", "bar"},
- []string{" FOO ", " BAR "}},
+ []string{" FOO ", " BAR "},
+ },
// errors
- {"missing end", `{{define "foo"}} FOO `, hasError,
+ {
+ "missing end", `{{define "foo"}} FOO `, hasError,
+ nil,
+ nil,
+ },
+ {
+ "malformed name", `{{define "foo}} FOO `, hasError,
nil,
- nil},
- {"malformed name", `{{define "foo}} FOO `, hasError,
nil,
- nil},
+ },
}
func TestMultiParse(t *testing.T) {
// by the contents of "stylesheet", but if the internal map associating
// names with templates is built in the wrong order, the empty block
// looks non-empty and this doesn't happen.
- var inlined = map[string]string{
+ inlined := map[string]string{
"stylesheet": `{{define "stylesheet"}}stylesheet{{end}}`,
"xhtml": `{{block "stylesheet" .}}{{end}}`,
}