chore: simplify

This commit is contained in:
andig 2024-05-18 11:54:08 +02:00
parent 15d9c4a59a
commit b5afd2d2ce
2 changed files with 30 additions and 32 deletions

View file

@ -21,23 +21,22 @@ func (t *Template) RenderDocumentation(product Product, lang string) ([]byte, er
values := t.Defaults(RenderModeDocs)
for index, p := range t.Params {
for k, v := range values {
if p.Name != k {
continue
}
v, ok := values[p.Name]
if !ok {
continue
}
switch p.Type {
case TypeStringList:
for _, e := range v.([]string) {
t.Params[index].Values = append(p.Values, yamlQuote(e))
}
default:
switch v := v.(type) {
case string:
t.Params[index].Value = yamlQuote(v)
case int:
t.Params[index].Value = strconv.Itoa(v)
}
switch p.Type {
case TypeStringList:
for _, e := range v.([]string) {
t.Params[index].Values = append(p.Values, yamlQuote(e))
}
default:
switch v := v.(type) {
case string:
t.Params[index].Value = yamlQuote(v)
case int:
t.Params[index].Value = strconv.Itoa(v)
}
}
}

View file

@ -216,23 +216,22 @@ func (t *Template) RenderProxyWithValues(values map[string]interface{}, lang str
t.ModbusParams("", values)
for index, p := range t.Params {
for k, v := range values {
if p.Name != k {
continue
}
v, ok := values[p.Name]
if !ok {
continue
}
switch p.Type {
case TypeStringList:
for _, e := range v.([]string) {
t.Params[index].Values = append(p.Values, yamlQuote(e))
}
default:
switch v := v.(type) {
case string:
t.Params[index].Value = yamlQuote(v)
case int:
t.Params[index].Value = strconv.Itoa(v)
}
switch p.Type {
case TypeStringList:
for _, e := range v.([]string) {
t.Params[index].Values = append(p.Values, yamlQuote(e))
}
default:
switch v := v.(type) {
case string:
t.Params[index].Value = yamlQuote(v)
case int:
t.Params[index].Value = strconv.Itoa(v)
}
}
}