Skip to content

jumpper/jumpper

develop
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
doc
 
 
 
 
 
 
 
 
 
 
 
 
 
 

jumpper

Swift 5.2 Swift Package Manager Mac + Linux jumpper tests License codebeat badge

Buy Me A Coffee

-----

Welcome to jumpper. Is an open source framework, which is independent of other web frameworks or toolkits available on the market, such as Vapor, Kitura and Perfect. It can be used in conjunction with any of them and even alone. This shows how simple it is to build HTML pages using only Swift.

The idea of this library is to facilitate the creation of static or dynamic pages.

About 10 years ago I developed a library similar to this one, but in another language, it streamlined many projects that I developed.

I decided to bring these concepts to the language I use today.

The project is still under development, feel free to collaborate and leave suggestions, fork and share.

I hope it will be useful for more developers.

Let`s code.

Documentation

Using in Package.swift

// swift-tools-version:5.6
import PackageDescription

let package = Package(
    name: "assessment",
    platforms: [
       .macOS(.v12)
    ],
    dependencies: [
        .package(url: "https://github.com/vapor/vapor.git", from: "4.0.0"),
        .package(url: "https://github.com/jumpper/jumpper.git", from: "0.0.9")
    ],
    targets: [
        .target(
            name: "App",
            dependencies: [
                .product(name: "Vapor", package: "vapor"),
                .product(name: "jumpper", package: "jumpper")
            ]
        ),
        .executableTarget(name: "Run", dependencies: [.target(name: "App")]),
        .testTarget(name: "AppTests", dependencies: [
            .target(name: "App"),
            .product(name: "XCTVapor", package: "vapor"),
        ])
    ]
)

Vapor usage

Need Leaf installed

import jumpper
import Leaf
import Vapor

router.get { req -> Future<View> in
     let div = Div()
     div.add("My first div with jumpper")
     return try req.view().render("base", ["title": "Hello jumpper", "body": div.getString()])
}

Without Leaf

import jumpper
import Vapor


protocol JumpperPageProtocol {
    func render() throws -> EventLoopFuture<Response>
}

public final class IndexPage: JumpperPageProtocol {
    // MARK: - Render

    public func render() throws -> EventLoopFuture<Response> {
        let response = Response()
        
        let divC = Div()
        response.body = .init(string: divC.getString())
        return response.encodeResponse(status: .ok, headers: HTTPHeaders.init([("Content-Type", "text/html; charset=UTF-8")]), for: request)
    }
}

jumpper vapor project demo

Elements Video Demo

Watch the video

About

A simple framework for creating HTML with Swift

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages