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
Earn up to 16% annual interest with Nexo. Icon
Earn up to 16% annual interest with Nexo.

Let your crypto work for you

Put idle assets to work with competitive interest rates, borrow without selling, and trade with precision. All in one platform. Geographic restrictions, eligibility, and terms apply.
Get started with Nexo.
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