Change map -> struct

This commit is contained in:
PedroEdiaz
2025-06-17 11:43:52 -06:00
parent 81febcef74
commit fedfd70c50
4 changed files with 51 additions and 22 deletions

30
decode.odin Normal file
View File

@@ -0,0 +1,30 @@
package mustache
import "base:runtime"
import "core:reflect"
import "core:log"
decode :: proc( v: any, key: string ) -> string {
if v == nil do return ""
ti := runtime.type_info_base(type_info_of(v.id))
a := any{v.data, ti.id}
#partial switch info in ti.variant {
case runtime.Type_Info_Struct:
return decode( reflect.struct_field_value_by_name(v, key), ".")
case runtime.Type_Info_String:
switch s in a {
case string:
return string(s)
case cstring:
return string(s)
}
}
return ""
}