From bee9d22b7510644e0cedf8d3969e88b9a8df76c7 Mon Sep 17 00:00:00 2001 From: bep Date: Sun, 7 Jun 2015 18:35:28 +0200 Subject: [PATCH] Add support for template.URL Fixes #13 --- cast_test.go | 1 + caste.go | 2 ++ 2 files changed, 3 insertions(+) diff --git a/cast_test.go b/cast_test.go index 3fa717f..a202b7b 100644 --- a/cast_test.go +++ b/cast_test.go @@ -37,6 +37,7 @@ func TestToString(t *testing.T) { 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(template.URL("http://somehost.foo")), "http://somehost.foo") assert.Equal(t, ToString(foo), "one more time") assert.Equal(t, ToString(nil), "") } diff --git a/caste.go b/caste.go index 58d72df..9ed19ad 100644 --- a/caste.go +++ b/caste.go @@ -194,6 +194,8 @@ func ToStringE(i interface{}) (string, error) { return string(s), nil case template.HTML: return string(s), nil + case template.URL: + return string(s), nil case nil: return "", nil case fmt.Stringer: