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

Other Useful Business Software
Our Free Plans just got better! | Auth0 Icon
Our Free Plans just got better! | Auth0

With up to 25k MAUs and unlimited Okta connections, our Free Plan lets you focus on what you do best—building great apps.

You asked, we delivered! Auth0 is excited to expand our Free and Paid plans to include more options so you can focus on building, deploying, and scaling applications without having to worry about your security. Auth0 now, thank yourself later.
Try free now
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