Maxador / swift-html-vapor

Vapor plugin for type-safe, transformable HTML views.

Home Page:https://www.pointfree.co/blog/posts/17-type-safe-html-with-vapor

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

swift-html-vapor

Swift 4.1 Linux CI @pointfreeco

Vapor plugin for type-safe, transformable HTML views using swift-html.

Motivation

The most popular choice for rendering HTML in a Vapor web app is to use the Leaf templating language, but it exposes your application to runtime errors and invalid HTML. Our plugin prevents these runtime issues at compile-time by embedding HTML directly into Swift’s powerful type system. It uses the swift-html DSL for constructing HTML documents using plain Swift data structures.

Example

To use the plugin all you have to do is return a Node value from your router callback:

import HtmlVaporSupport
import Vapor

let app = try Application()
let router = try app.make(Router.self)

router.get("/") { _ in
  h1(["Hello, type-safe HTML on Vapor!"])
}

try app.run()

Installation

If you want to use swift-html-vapor in a project that uses SwiftPM, it's as simple as adding a dependencies clause to your Package.swift:

dependencies: [
  .package(url: "https://github.com/pointfreeco/swift-html-vapor.git", from: "0.1.0")
]

Xcode Sub-project

Submodule, clone, or download swift-html-vapor, and drag HtmlVaporSupport.xcodeproj into your project.

License

All modules are released under the MIT license. See LICENSE for details.

About

Vapor plugin for type-safe, transformable HTML views.

https://www.pointfree.co/blog/posts/17-type-safe-html-with-vapor

License:MIT License


Languages

Language:Swift 68.2%Language:Makefile 28.1%Language:Dockerfile 3.7%