[Pitch] Community-maintained HTML and CSS Swift types

I tried implementing swift-html-types into HTMLKit with minor success. There is some key data and logic missing before it can be used. Some improvements I've thought of terms of generics, logic, memory footprint, and functionality:

(there are probably more)

list
  • removing the lowercase typealias (other libraries can do this if they wish)
  • adding support for dynamic values (currently cannot; literals are required)
  • support for optional values in more areas
  • better naming of protocols/types by prefixing some with HTML
  • use camelCase for variable names (not html styled; other libraries can do this if they wish)
  • an easy way to check if the element is a void element (something like @inlinable public static var isVoid: Bool { true })
  • having an attribute value type per Attribute
  • adding some missing attributes (ARIA, Command, CommandFor, etc)
    • Form is missing a acceptCharset in the initializer
  • rearranging stored values for minimal byte usage (obviously can't with some elements)
  • packing data when applicable (like the Button element)
  • replacing the following patterns with @inlinable public static var _: Self/String { "xyz" }
    • public static let _: Self = "xyz"
    • public static let _: String = "xyz"

I agree, wasted bytes is sub-optimal. Compile-time rendering is the only solution to avoid this without sacrificing convenience or functionality. How big of a problem is it really? What HTML libraries have you used that are better? benchmark comparing different library's throughput/rendering performance

That is a great feature suggestion!

1 Like