github.com/kyleu/dbaudit@v0.0.2-0.20240321155047-ff2f2c940496/views/components/view/Any.html (about) 1 <!-- Content managed by Project Forge, see [projectforge.md] for details. --> 2 {% import ( 3 "fmt" 4 5 "github.com/kyleu/dbaudit/app/lib/types" 6 "github.com/kyleu/dbaudit/views/components" 7 ) %} 8 9 {% func Any(x any, t *types.Wrapped) %}{% stripspace %} 10 {% switch t.Key() %} 11 {% case types.KeyAny %} 12 {%= Default(x, t.String()) %} 13 {% case types.KeyBit %} 14 {%= Default(x, t.String()) %} 15 {% case types.KeyBool %} 16 {%= Bool(x.(bool)) %} 17 {% case types.KeyByte %} 18 {%= Default(x, t.String()) %} 19 {% case types.KeyChar %} 20 {%= Default(x, t.String()) %} 21 {% case types.KeyDate %} 22 {%= Default(x, t.String()) %} 23 {% case types.KeyEnum %} 24 <span title="enum:{%s t.T.(*types.Enum).Ref %}">{%v x %}</span> 25 {% case types.KeyEnumValue %} 26 {%= Default(x, t.String()) %} 27 {% case types.KeyError %} 28 {%= Default(x, t.String()) %} 29 {% case types.KeyFloat %} 30 {%= Float(x) %} 31 {% case types.KeyInt %} 32 {%= Int(x) %} 33 {% case types.KeyJSON %} 34 {%= components.JSON(x) %} 35 {% case types.KeyList %} 36 {%= Default(x, t.String()) %} 37 {% case types.KeyMap %} 38 {%= Default(x, t.String()) %} 39 {% case types.KeyMethod %} 40 {%= Default(x, t.String()) %} 41 {% case types.KeyNil %} 42 {%= Default(x, t.String()) %} 43 {% case types.KeyOption %} 44 {% if x == nil %} 45 <em>∅</em> 46 {% else %} 47 {%= Any(x, t.T.(*types.Option).V) %} 48 {% endif %} 49 {% case types.KeyRange %} 50 {%= Default(x, t.String()) %} 51 {% case types.KeyReference %} 52 {%= Default(x, t.String()) %} 53 {% case types.KeySet %} 54 {%= Default(x, t.String()) %} 55 {% case types.KeyString %} 56 {%= String(x.(string)) %} 57 {% case types.KeyTime %} 58 {%= Default(x, t.String()) %} 59 {% case types.KeyTimestamp %} 60 {%= Default(x, t.String()) %} 61 {% case types.KeyTimestampZoned %} 62 {%= Default(x, t.String()) %} 63 {% case types.KeyUnknown %} 64 {%= Default(x, t.String()) %} 65 {% case types.KeyUUID %} 66 {%= Default(x, t.String()) %} 67 {% case types.KeyValueMap %} 68 {%= Default(x, t.String()) %} 69 {% case types.KeyXML %} 70 {%= Default(x, t.String()) %} 71 {% default %} 72 {%= Default(x, t.String()) %} 73 {% endswitch %} 74 {% endstripspace %}{% endfunc %} 75 76 {% func Default(x any, t string) %}{% stripspace %} 77 {% code msg := fmt.Sprintf("unhandled type: %s (%T)", t, x) %} 78 <span title="{%s msg %}">{%v x %}</span> 79 {% endstripspace %}{% endfunc %} 80 81 {% func Type(v types.Type) %}{% stripspace %} 82 {%s v.String() %} 83 {% endstripspace %}{% endfunc %}