Giter Club home page Giter Club logo

swift-html-kitura's Introduction

swift-html-kitura has been deprecated

With IBM discontinuing its involvement in server-side Swift, we are choosing to deprecate support for this library. It will remain in an archived state as an example of how to integrate with swift-html.


swift-html-kitura

Swift 5 [Linux CI](https://trav is-ci.org/pointfreeco/swift-html-kitura) @pointfreeco

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

Motivation

The most popular choice for rendering HTML in a Kitura web app is to use the Stencil 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.

Usage

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

import HtmlKituraSupport
import Kitura

let router = Router()

router.get("/") { request, response, next in
  response.send(
    Node.h1("Hello, type-safe HTML on Kitura!")
  )
  next()
}

Kitura.addHTTPServer(onPort: 8080, with: router)
Kitura.run()

Take it for a spin

We've included a sample Kitura application in this repo to show off its usage. To run the app immediately, simply do:

  • swift run HtmlKituraSupportExample
  • Open your browser to http://localhost:8080

The HTML for that page is constructed and rendered with swift-html!

If you want to run the app in Xcode so that you can play around with the HTML, try this:

  • git clone https://github.com/pointfreeco/swift-html-kitura
  • cd swift-html-kitura
  • make xcodeproj
  • Select the HtmlKituraSupportExample target
  • Build and run cmd+R
  • Open your browser to http://localhost:8080

Installation

If you want to use swift-html-kitura 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-kitura.git", from: "0.3.0")
]

Xcode Sub-project

Submodule, clone, or download swift-html-kitura, and drag HtmlKituraSupport.xcodeproj into your project.

License

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

swift-html-kitura's People

Contributors

stephencelis avatar mbrandonw avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.