-
"""
for todo in todos where filter.includes(todo) {
html += item(todo, filter: filter, editing: todo.id == editing)
}
html += """
/// The three views of a list, named as the contract's `filter` field names them. public enum Filter: String, Sendable, CaseIterable { case all, active, completed /// A missing or unknown value means `all`. init(field: String?) { self = field.flatMap(Filter.init(rawValue:)) ?? .all } var path: String { switch self { case .all: "/" case .active: "/active" case .completed: "/completed" } } func includes(_ todo: Todo) -> Bool { switch self { case .all: true case .active: !todo.completed case .completed: todo.completed } } } /// Server-rendered HTML. Everything a visitor typed goes through `escape`. /// /// The markup follows `shared/reference.html`. The controls marked /// `class="nojs"` are what a page without JavaScript uses; `app.css` lays the /// toggle buttons exactly over the checkboxes they stand in for, and hides /// every `nojs` control once the `js` class is on ``. enum Page { static let language = "Swift" static func document(todos: [Todo], filter: Filter, editing: Int?, version: String) -> String { var html = """