@resultBuilder struct HTMLBuilder { static func buildBlock(_ components: String...) -> String { components.joined(separator: "\n") } static func buildOptional(_ component: String?) -> String { component ?? "" } static func buildEither(first component: String) -> String { component } static func buildEither(second component: String) -> String { component } } func html(@HTMLBuilder content: () -> String) -> String { "\n\(content())\n" } let page = html { "Hello" "" "

Welcome

" "" }