"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tpl/internal/go_templates/htmltemplate/template_test.go" between
hugo-0.80.0.tar.gz and hugo-0.81.0.tar.gz

About: Hugo is a static site generator that takes a source directory of Markdown files and templates and uses these as input to create a complete website (written in Go).

template_test.go  (hugo-0.80.0):template_test.go  (hugo-0.81.0)
skipping to change at line 16 skipping to change at line 16
package template_test package template_test
import ( import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"strings" "strings"
"testing" "testing"
. "github.com/gohugoio/hugo/tpl/internal/go_templates/htmltemplate" . "github.com/gohugoio/hugo/tpl/internal/go_templates/htmltemplate"
"github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate/parse" / / https://golang.org/issue/12996
) )
func TestTemplateClone(t *testing.T) { func TestTemplateClone(t *testing.T) {
// https://golang.org/issue/12996
orig := New("name") orig := New("name")
clone, err := orig.Clone() clone, err := orig.Clone()
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
if len(clone.Templates()) != len(orig.Templates()) { if len(clone.Templates()) != len(orig.Templates()) {
t.Fatalf("Invalid length of t.Clone().Templates()") t.Fatalf("Invalid length of t.Clone().Templates()")
} }
const want = "stuff" const want = "stuff"
skipping to change at line 166 skipping to change at line 167
if err := json.Unmarshal(trimmed, &got); err != nil { if err := json.Unmarshal(trimmed, &got); err != nil {
t.Fatalf("Cannot parse JS string %q as JSON: %v", trimmed[1:len(trimmed)-1], err) t.Fatalf("Cannot parse JS string %q as JSON: %v", trimmed[1:len(trimmed)-1], err)
} }
if got != tt.in { if got != tt.in {
t.Errorf("Serialization changed the string value: got %q want %q", got, tt.in) t.Errorf("Serialization changed the string value: got %q want %q", got, tt.in)
} }
}) })
} }
} }
func TestSkipEscapeComments(t *testing.T) {
c := newTestCase(t)
tr := parse.New("root")
tr.Mode = parse.ParseComments
newT, err := tr.Parse("{{/* A comment */}}{{ 1 }}{{/* Another comment */}
}", "", "", make(map[string]*parse.Tree))
if err != nil {
t.Fatalf("Cannot parse template text: %v", err)
}
c.root, err = c.root.AddParseTree("root", newT)
if err != nil {
t.Fatalf("Cannot add parse tree to template: %v", err)
}
c.mustExecute(c.root, nil, "1")
}
type testCase struct { type testCase struct {
t *testing.T t *testing.T
root *Template root *Template
} }
func newTestCase(t *testing.T) *testCase { func newTestCase(t *testing.T) *testCase {
return &testCase{ return &testCase{
t: t, t: t,
root: New("root"), root: New("root"),
} }
 End of changes. 3 change blocks. 
1 lines changed or deleted 18 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)