sahandnayebaziz / Hypertext
Licence: mit
Any-way-you-want-it, type-safe HTML in Swift.
Stars: ✭ 236
Projects that are alternatives of or similar to Hypertext
Vapor
💧 A server-side Swift HTTP web framework.
Stars: ✭ 21,194 (+8880.51%)
Mutual labels: server-side-swift, server
Venice
Coroutines, structured concurrency and CSP for Swift on macOS and Linux.
Stars: ✭ 1,501 (+536.02%)
Mutual labels: server-side-swift, server
Swiftserverside Vapor
🦄 Swift server open source projects based on the Swift 4.1 and Vapor 3 frameworks. (Swift 服务端开源项目)
Stars: ✭ 588 (+149.15%)
Mutual labels: server-side-swift, server
Kitura
A Swift web framework and HTTP server.
Stars: ✭ 7,533 (+3091.95%)
Mutual labels: server-side-swift, server
Hummingbird
Lightweight, flexible HTTP server framework written in Swift
Stars: ✭ 114 (-51.69%)
Mutual labels: server-side-swift, server
Flock
Automated deployment of Swift projects to servers
Stars: ✭ 127 (-46.19%)
Mutual labels: server-side-swift, server
Jupyter server
The backend—i.e. core services, APIs, and REST endpoints—to Jupyter web applications.
Stars: ✭ 217 (-8.05%)
Mutual labels: server
Hydux
A light-weight type-safe Elm-like alternative for Redux ecosystem, inspired by hyperapp and Elmish
Stars: ✭ 216 (-8.47%)
Mutual labels: type-safe
Yin
The efficient and elegant JSON:API 1.1 server library for PHP
Stars: ✭ 214 (-9.32%)
Mutual labels: server
Nstack
Type-safe, composable microservices for data analytics
Stars: ✭ 219 (-7.2%)
Mutual labels: type-safe
Twist
A light script for you to setup shadowsocks-libev server with high-speed connections and newest powerful features
Stars: ✭ 229 (-2.97%)
Mutual labels: server
Ocsinventory Server
Communication server of OCS Inventory
Stars: ✭ 214 (-9.32%)
Mutual labels: server
Playmaker
Fdroid repository manager fetching apps from Play Store
Stars: ✭ 236 (+0%)
Mutual labels: server
Beasthttp
Provides helper tools for creating RESTful services using Boost.Beast
Stars: ✭ 227 (-3.81%)
Mutual labels: server
Hls Vod
HTTP Live Streaming with on-the-fly encoding of any video file for Web/Apple TV/iPhone/iPad/iPod
Stars: ✭ 221 (-6.36%)
Mutual labels: server
Compose valid HTML in Swift any way you want to.
Usage
import Hypertext
title { "hello world." }.render()
// <title>hello world.</title>
head { title { "hello world." } }.render()
// <head><title>hello world.</title></head>
head { title { "hello world." } }.render(startingWithSpaces: 0, indentingWithSpaces: 2)
// <head>
// <title>
// hello world.
// </title>
// </head>
Requirements
- Swift 3.0+
Full usage
-
Rendering a tag
div().render() // <div></div>
-
Rendering a tag with child text
div { "hello world." }.render() // <div>hello world.</div>
-
Rendering a tag with a child tag
div { img() }.render() // <div><img/></div>
-
Rendering a tag with multiple child tags
div { [img(), img(), img()] }.render() // <div><img/><img/><img/></div>
-
Rendering a tag with attributes
link(["rel": "stylesheet", "type":"text/css", "href":"./style.css"]).render() // <link rel="stylesheet" type="text/css" href="./style.css"/>
-
Rendering a tag with attributes and children
div(["class": "container"]) { "hello world." } // <div class="container">hello world.</div>
-
Rendering a doctype declaration
doctype(.html5).render() // <!DOCTYPE html>
-
Rendering unminified, with newlines and indentation
head { title { "hello world." } }.render(startingWithSpaces: 0, indentingWithSpaces: 2) // <head> // <title> // hello world. // </title> // </head>
-
Rendering a tag in a novel way, any way you want to
func createTitleTag(forPageNamed pageName: String) -> title { return title { "Hypertext - \(pageName)" } } head { createTitleTag(forPageNamed: "Documentation") }.render() // <head><title>Hypertext - Documentation</title></head>
-
Rendering a custom tag
public class myNewTag: tag { override public var isSelfClosing: Bool { return true } } myNewTag().render() // <my-new-tag/>
-
Rendering a custom type by adopting the protocol
Renderable
extension MyType: Renderable { public func render() -> String { ... } public func render(startingWithSpaces: Int, indentingWithSpaces: Int) -> String { ... } }
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].