HTMLDocument

A type that represents a full HTML document.

HtmlDocument.swift:23
protocol HTMLDocument : HTML
Browse conforming types

Provides a simple structure to model top-level HTML types. A default HTML/content implementation takes your title, head, body and renders them into a full HTML document. Optionally properties for lang and dir can be provided.

struct MyPage: HTMLDocument {
  var title = "Hello, World!"
  var lang = "en"

  var head: some HTML {
    meta(.name(.viewport), .content("width=device-width, initial-scale=1.0"))
  }

  var body: some HTML {
    h1 { "Hello, World!" }
    p { "This is a simple HTML document." }
  }
}