UIWebKit icon indicating copy to clipboard operation
UIWebKit copied to clipboard

Create web pages for Vapor in Swift.

trafficstars

UIWebKit Icon

UIWebKit

Build Status Documentation Coverage

Create UI's for Vapor without HTML.

Example:

Create a class to control the creation of a web page:

import Foundation
import UIWebKit
import Vapor

final class MainView: UIWebPage {

    override func configure() {
        addSectionText()
        addHead()
    }

    func addSectionText() {
        let content = UIElement(element: Element.p)
        content.add("Text")
        content.attributes["style"] = "font-family: Roboto, sans-serif;"
        for _ in 0...10 {
            section.add(content)
        }
    }

    func addHead() {
        let title = UIElement(element: .title)
        title.add("UIWebKit Example")
        let link = UIElement(element: .link)
        link.attributes["rel"] = "stylesheet"
        link.attributes["href"] = "https://fonts.googleapis.com/css?family=Roboto"
        head.add(title)
        head.add(link)
    }
}

Use the class to create the page:

drop.get("about") { req in
    return MainView()
}

Documentation:

You can get the API documentation here.

Contributing:

Read the contribution guidlines here.

License:

All code is under the MIT license agreement.