(groups map[string]*Group)
| 15 | } |
| 16 | |
| 17 | func ProcessGroups(groups map[string]*Group) { |
| 18 | for groupID, group := range groups { |
| 19 | groupContent := group.Content |
| 20 | groupFileContent := "" |
| 21 | |
| 22 | if strings.TrimSpace(group.Content) != "" { |
| 23 | if group.Name != "" { |
| 24 | groupContent = "\n" + `<div className="group-name">` + group.Name + `</div>` + "\n\n" + groupContent |
| 25 | } |
| 26 | |
| 27 | groupImportContent := "" |
| 28 | for _, partialFile := range *group.Imports { |
| 29 | groupImportContent = groupImportContent + GetPartialImport(partialFile, group.File) |
| 30 | } |
| 31 | |
| 32 | if groupImportContent != "" { |
| 33 | groupImportContent = groupImportContent + "\n\n" |
| 34 | } |
| 35 | |
| 36 | groupFileContent = fmt.Sprintf(`%s<div className="group" data-group="%s">%s`+"\n"+`</div>`, groupImportContent, groupID, groupContent) |
| 37 | } |
| 38 | |
| 39 | err := os.MkdirAll(filepath.Dir(group.File), os.ModePerm) |
| 40 | if err != nil { |
| 41 | panic(err) |
| 42 | } |
| 43 | |
| 44 | err = os.WriteFile(group.File, []byte(groupFileContent), os.ModePerm) |
| 45 | if err != nil { |
| 46 | panic(err) |
| 47 | } |
| 48 | } |
| 49 | } |
no test coverage detected