struct ContentButtons { struct Item { let icon: PageIcon let filePath: String let text: String let downloadFileName: String? init(icon: PageIcon, filePath: String, text: String, downloadFileName: String? = nil) { self.icon = icon self.filePath = filePath self.text = text self.downloadFileName = downloadFileName } } let items: [Item] init(items: [Item]) { self.items = items } var content: String { var result = "

" for item in items { addButton(of: item, to: &result) } result += "

" return result } private func addButton(of item: Item, to result: inout String) { let downloadText = item.downloadFileName.map { " download='\($0)'" } ?? "" result += "" result += "\(item.text)" result += "" } }