Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
linkdata committed May 24, 2024
1 parent cf4e0bd commit 2eec519
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 66 deletions.
16 changes: 0 additions & 16 deletions template.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,6 @@ func (t Template) ServeHTTP(wr http.ResponseWriter, r *http.Request) {
t.Log(t.NewRequest(r).NewElement(t).JawsRender(wr, nil))
}

/*
// MustTemplate resolves 'v' to a *template.Template or panics.
func (jw *Jaws) MustTemplate(v any) (tp *template.Template) {
switch v := v.(type) {
case *template.Template:
tp = v
case string:
tp = jw.Lookup(v)
}
if tp == nil {
panic(fmt.Errorf("template not found: %T(%v)", v, v))
}
return
}
*/
func (jw *Jaws) NewTemplate(name string, dot any) Template {
return Template{Jaws: jw, Template: name, Dot: dot}
}
50 changes: 0 additions & 50 deletions template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,53 +45,3 @@ func TestTemplate_As_Handler(t *testing.T) {
t.Error(got)
}
}

/*func TestRequest_MustTemplate(t *testing.T) {
rq := newTestRequest()
defer rq.Close()
tests := []struct {
name string
arg any
wantTp *template.Template
}{
{"*template.Template", rq.jw.testtmpl, rq.jw.testtmpl},
{"named template", "testtemplate", rq.jw.testtmpl},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if gotTp := rq.Jaws.MustTemplate(tt.arg); gotTp != tt.wantTp {
t.Errorf("Request.MustTemplate() = %v, want %v", gotTp, tt.wantTp)
}
})
}
}
func TestRequest_MustTemplate_Panics(t *testing.T) {
rq := newTestRequest()
defer rq.Close()
tests := []struct {
name string
arg any
wantTp *template.Template
}{
{"nil", nil, rq.jw.testtmpl},
{"nosuchtemplate", "nosuchtemplate", rq.jw.testtmpl},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
defer func() {
x := recover()
if e, ok := x.(error); ok {
if strings.Contains(e.Error(), tt.name) {
return
}
}
t.Fail()
}()
rq.Jaws.MustTemplate(tt.arg)
t.Fail()
})
}
}*/

0 comments on commit 2eec519

Please sign in to comment.