Add support for the other html template types
This commit is contained in:
parent
ee7b3e0353
commit
a84ea1c7ec
@ -38,6 +38,9 @@ func TestToString(t *testing.T) {
|
||||
assert.Equal(t, ToString([]byte("one time")), "one time")
|
||||
assert.Equal(t, ToString(template.HTML("one time")), "one time")
|
||||
assert.Equal(t, ToString(template.URL("http://somehost.foo")), "http://somehost.foo")
|
||||
assert.Equal(t, ToString(template.JS("(1+2)")), "(1+2)")
|
||||
assert.Equal(t, ToString(template.CSS("a")), "a")
|
||||
assert.Equal(t, ToString(template.HTMLAttr("a")), "a")
|
||||
assert.Equal(t, ToString(foo), "one more time")
|
||||
assert.Equal(t, ToString(nil), "")
|
||||
assert.Equal(t, ToString(true), "true")
|
||||
|
6
caste.go
6
caste.go
@ -206,6 +206,12 @@ func ToStringE(i interface{}) (string, error) {
|
||||
return string(s), nil
|
||||
case template.URL:
|
||||
return string(s), nil
|
||||
case template.JS:
|
||||
return string(s), nil
|
||||
case template.CSS:
|
||||
return string(s), nil
|
||||
case template.HTMLAttr:
|
||||
return string(s), nil
|
||||
case nil:
|
||||
return "", nil
|
||||
case fmt.Stringer:
|
||||
|
Loading…
Reference in New Issue
Block a user