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
Planfix: Manage Projects, Team's Tasks and Business Processes Icon
Planfix: Manage Projects, Team's Tasks and Business Processes

All-in-One Enterprise-Level Software is Now Available for SMB

Planfix is like a souped-up business process management system for folks who really know their stuff. It's built to help you dive deeper and gives you more options than your run-of-the-mill project and task management systems. Best part? Even small businesses and non-profits can get in on the action.
Learn More
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