Add support for HTML to String
diff --git a/cast_test.go b/cast_test.go
index a7ab1a8..13318a4 100644
--- a/cast_test.go
+++ b/cast_test.go
@@ -9,6 +9,7 @@
"testing"
"github.com/stretchr/testify/assert"
+ "html/template"
)
func TestToInt(t *testing.T) {
@@ -34,6 +35,7 @@
assert.Equal(t, ToString(8), "8")
assert.Equal(t, ToString(8.12), "8.12")
assert.Equal(t, ToString([]byte("one time")), "one time")
+ assert.Equal(t, ToString(template.HTML("one time")), "one time")
assert.Equal(t, ToString(foo), "one more time")
assert.Equal(t, ToString(nil), "")
}
diff --git a/caste.go b/caste.go
index 9f5916a..086a5b1 100644
--- a/caste.go
+++ b/caste.go
@@ -8,6 +8,7 @@
import (
"errors"
"fmt"
+ "html/template"
"reflect"
"strconv"
"time"
@@ -130,6 +131,8 @@
return strconv.FormatInt(int64(i.(int)), 10), nil
case []byte:
return string(s), nil
+ case template.HTML:
+ return string(s), nil
case nil:
return "", nil
default: