GithubHelp home page GithubHelp logo

htmlkit-vapor-provider's Introduction

HTMLKit-Vapor-Provider

A provider that makes it possible to use HTMLKit with Vapor 4. If you are using Vapor 3, check this provider out.

Getting started

Installation

Add the packages as dependecies to your package.

/// [Package.swift]
...
dependencies: [
    ...
    ///1. Add the package
    .package(name: "HTMLKitVaporProvider", url: "https://github.com/vapor-community/htmlkit-vapor-provider.git", from: "1.2.0")
],
.targets: [
    .target(
    ...
        dependencies: [
            ...
            /// 2. Add the product
            .product(name: "HTMLKitVaporProvider", package: "HTMLKitVaporProvider")
        ]
    ),
    ...

Implementation

This will expose HTMLKit on Request and Application as shown below.

Preload

You can preload a layout to optimize rendering.

/// [configure.swift]

app.htmlkit.add(view: UserTemplate())

Rendering

/// [SimpleController.swift]

...
/// Returns a Response
try req.htmlkit.render(UserTemplate.self, with: user)

/// Returns a View
try req.htmlkit.render(view: UserTemplate.self, with: user)

/// Returns an EventLoopFuture<View> and will not require the preload
UserTemplate().render(with: user, for: req)

Localization

You can also set a localizationPath to enable Lingo.

/// [configure.swift]

app.htmlkit.localizationPath = "Resources/Localization"
app.htmlkit.defaultLocale = "nb"

htmlkit-vapor-provider's People

Contributors

matsmoll avatar mattesmohr avatar renaudjenny avatar rinsuki avatar thecb4 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

htmlkit-vapor-provider's Issues

Documentation, examples

The readme ir really poor in general informations... If I understood it's not a real vapor integration but only a factory accessible through Application.htmlkit property ? If I succeed to integrate HTMLKit to my project I would provide some example of how to use it in a Vapor context.

Other : property htmlkit of Request or Application object are inaccessible ?.

A real implentation accessible through the default request.view.render is a good idea ? (need some config like app.views.use(HTMLKitRendererProvider.self))

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.