A Swift DSL for type-safe, extensible, and transformable HTML documents. The popular choice for rendering HTML in Swift these days is to use templating languages, but they expose your application to runtime errors and invalid HTML. Our library prevents these runtime issues at compile-time by embedding HTML directly into Swift’s powerful type system. Underneath the hood these tag functions html, body, h1, etc., are just creating and nesting instances of a Node type, which is a simple Swift enum. Because Node is just a simple Swift type, we can transform it in all kinds of interesting ways. For a silly example, what if we wanted to remove all instances of exclamation marks from our document? We even provide plug-in libraries that reduce the friction of using this library with Kitura and Vapor.

Features

  • HTML documents can be created in a tree-like fashion
  • Type-safe, extensible, and transformable HTML documents
  • Underneath the hood these tag functions html, body, h1, etc., are just creating and nesting instances of a Node type
  • Because we are embedding our DSL in Swift we can take advantage of some advanced Swift features to add an extra layer of safety
  • We can strengthen many HTML APIs to force their true types rather than just relying on strings
  • The core of the library is a single enum with 6 cases

Project Samples

Project Activity

See All Activity >

Categories

HTML/XHTML

License

MIT License

Follow swift-html

swift-html Web Site

You Might Also Like
MongoDB Atlas runs apps anywhere Icon
MongoDB Atlas runs apps anywhere

Deploy in 115+ regions with the modern database for every enterprise.

MongoDB Atlas gives you the freedom to build and run modern applications anywhere—across AWS, Azure, and Google Cloud. With global availability in over 115 regions, Atlas lets you deploy close to your users, meet compliance needs, and scale with confidence across any geography.
Start Free
Rate This Project
Login To Rate This Project

User Reviews

Be the first to post a review of swift-html!

Additional Project Details

Programming Language

Swift

Related Categories

Swift HTML XHTML

Registered

2023-05-04