Remove types from each string entry for a type map string interface
- commit
- 58590c56bea03ae8a11b693c636f0a9be5edc761
- author
- bnema · · 2023-09-03 05:11 UTC
- committer
- bnema · · 2023-09-04 06:59 UTC
- parent
- 68f563a
- signature
- unsigned
2 files · +4 -25
M internal/ui/templates/components.gohtml +2 -2
| @@ -4,7 +4,7 @@ | |||
| 4 | 4 | <h1 | |
| 5 | 5 | class="text-5xl fw100 animate-bounce-alt animate-count-infinite animate-duration-1s" | |
| 6 | 6 | > | |
| 7 | - | {{ .Body.Header.HelloWorld }} | |
| 7 | + | {{ .body.header.helloworld }} | |
| 8 | 8 | </h1> | |
| 9 | 9 | </div> | |
| 10 | 10 | ||
| @@ -12,6 +12,6 @@ | |||
| 12 | 12 | <h1 | |
| 13 | 13 | class="text-5xl fw100 animate-bounce-alt animate-count-infinite animate-duration-1s" | |
| 14 | 14 | > | |
| 15 | - | {{ .Body.Div.Hello }} | |
| 15 | + | {{ .body.div.hello }} | |
| 16 | 16 | </h1> | |
| 17 | 17 | </div> | |
| @@ -4,7 +4,7 @@ | |||||
| 4 | <h1 | 4 | <h1 | ||
| 5 | class="text-5xl fw100 animate-bounce-alt animate-count-infinite animate-duration-1s" | 5 | class="text-5xl fw100 animate-bounce-alt animate-count-infinite animate-duration-1s" | ||
| 6 | > | 6 | > | ||
| 7 | - | {{ .Body.Header.HelloWorld }} | 7 | + | {{ .body.header.helloworld }} |
| 8 | </h1> | 8 | </h1> | ||
| 9 | </div> | 9 | </div> | ||
| 10 | 10 | ||||
| @@ -12,6 +12,6 @@ | |||||
| 12 | <h1 | 12 | <h1 | ||
| 13 | class="text-5xl fw100 animate-bounce-alt animate-count-infinite animate-duration-1s" | 13 | class="text-5xl fw100 animate-bounce-alt animate-count-infinite animate-duration-1s" | ||
| 14 | > | 14 | > | ||
| 15 | - | {{ .Body.Div.Hello }} | 15 | + | {{ .body.div.hello }} |
| 16 | </h1> | 16 | </h1> | ||
| 17 | </div> | 17 | </div> | ||
M pkg/utils/parser.go +2 -23
| @@ -9,29 +9,7 @@ import ( | |||
| 9 | 9 | ) | |
| 10 | 10 | ||
| 11 | 11 | // Yaml Parser | |
| 12 | - | type Meta struct { | |
| 13 | - | Title string `yaml:"title"` | |
| 14 | - | Description string `yaml:"description"` | |
| 15 | - | Keywords string `yaml:"keywords"` | |
| 16 | - | } | |
| 17 | - | ||
| 18 | - | type Header struct { | |
| 19 | - | Meta Meta `yaml:"meta"` | |
| 20 | - | HelloWorld string `yaml:"helloworld"` | |
| 21 | - | } | |
| 22 | - | ||
| 23 | - | type Body struct { | |
| 24 | - | Header Header `yaml:"header"` | |
| 25 | - | Div struct { | |
| 26 | - | Hello string `yaml:"hello"` | |
| 27 | - | } `yaml:"div"` | |
| 28 | - | } | |
| 29 | - | ||
| 30 | - | type LangData struct { | |
| 31 | - | Header Header `yaml:"header"` | |
| 32 | - | Body Body `yaml:"body"` | |
| 33 | - | } | |
| 34 | - | ||
| 12 | + | type LangData map[string]interface{} | |
| 35 | 13 | type YamlData struct { | |
| 36 | 14 | EN LangData `yaml:"en"` | |
| 37 | 15 | FR LangData `yaml:"fr"` | |
| @@ -59,6 +37,7 @@ func ReadDataFromYAML() (YamlData, error) { | |||
| 59 | 37 | if err := yaml.Unmarshal(content, &data); err != nil { | |
| 60 | 38 | return data, fmt.Errorf("failed to unmarshal strings.yaml: %w", err) | |
| 61 | 39 | } | |
| 40 | + | fmt.Println(data) | |
| 62 | 41 | ||
| 63 | 42 | return data, nil | |
| 64 | 43 | } | |
| @@ -9,29 +9,7 @@ import ( | |||||
| 9 | ) | 9 | ) | ||
| 10 | 10 | ||||
| 11 | // Yaml Parser | 11 | // Yaml Parser | ||
| 12 | - | type Meta struct { | 12 | + | type LangData map[string]interface{} |
| 13 | - | Title string `yaml:"title"` | |||
| 14 | - | Description string `yaml:"description"` | |||
| 15 | - | Keywords string `yaml:"keywords"` | |||
| 16 | - | } | |||
| 17 | - | ||||
| 18 | - | type Header struct { | |||
| 19 | - | Meta Meta `yaml:"meta"` | |||
| 20 | - | HelloWorld string `yaml:"helloworld"` | |||
| 21 | - | } | |||
| 22 | - | ||||
| 23 | - | type Body struct { | |||
| 24 | - | Header Header `yaml:"header"` | |||
| 25 | - | Div struct { | |||
| 26 | - | Hello string `yaml:"hello"` | |||
| 27 | - | } `yaml:"div"` | |||
| 28 | - | } | |||
| 29 | - | ||||
| 30 | - | type LangData struct { | |||
| 31 | - | Header Header `yaml:"header"` | |||
| 32 | - | Body Body `yaml:"body"` | |||
| 33 | - | } | |||
| 34 | - | ||||
| 35 | type YamlData struct { | 13 | type YamlData struct { | ||
| 36 | EN LangData `yaml:"en"` | 14 | EN LangData `yaml:"en"` | ||
| 37 | FR LangData `yaml:"fr"` | 15 | FR LangData `yaml:"fr"` | ||
| @@ -59,6 +37,7 @@ func ReadDataFromYAML() (YamlData, error) { | |||||
| 59 | if err := yaml.Unmarshal(content, &data); err != nil { | 37 | if err := yaml.Unmarshal(content, &data); err != nil { | ||
| 60 | return data, fmt.Errorf("failed to unmarshal strings.yaml: %w", err) | 38 | return data, fmt.Errorf("failed to unmarshal strings.yaml: %w", err) | ||
| 61 | } | 39 | } | ||
| 40 | + | fmt.Println(data) | |||
| 62 | 41 | ||||
| 63 | return data, nil | 42 | return data, nil | ||
| 64 | } | 43 | } | ||