Code Monkey home page Code Monkey logo

giraffe.dotliquid's Introduction

Giraffe

Giraffe.DotLiquid

DotLiquid templating engine http handlers for the Giraffe web framework.

NuGet Info

Linux, macOS and Windows Build Status

.NET Core

Build history

Table of contents

Documentation

The Giraffe.DotLiquid NuGet package adds additional HttpHandler functions to render DotLiquid templates in Giraffe.

dotLiquid

dotLiquid uses the DotLiquid template engine to set or modify the body of the HttpResponse. This http handler triggers a response to the client and other http handlers will not be able to modify the HTTP headers afterwards any more.

The dotLiquid handler requires the content type and the actual template to be passed in as two string values together with an object model. This handler is supposed to be used as the base handler for other http handlers which want to utilize the DotLiquid template engine (e.g. you could create an SVG handler on top of it).

Example:

open Giraffe
open Giraffe.DotLiquid

type Person =
    {
        FirstName : string
        LastName  : string
    }

let fooBar = { FirstName = "Foo"; LastName = "Bar" }

let template = "<html><head><title>DotLiquid</title></head><body><p>First name: {{ firstName }}<br />Last name: {{ lastName }}</p></body></html>"

let app =
    choose [
        route  "/foo" >=> dotLiquid "text/html" template fooBar
    ]

dotLiquidTemplate

dotLiquidTemplate uses the DotLiquid template engine to set or modify the body of the HttpResponse. This http handler triggers a response to the client and other http handlers will not be able to modify the HTTP headers afterwards any more.

This http handler takes a relative path of a template file, an associated model and the contentType of the response as parameters.

Example:

open Giraffe
open Giraffe.DotLiquid

type Person =
    {
        FirstName : string
        LastName  : string
    }

let fooBar = { FirstName = "Foo"; LastName = "Bar" }

let app =
    choose [
        route  "/foo" >=> dotLiquidTemplate "text/html" "templates/person.html" fooBar
    ]

dotLiquidHtmlTemplate

dotLiquidHtmlTemplate is the same as dotLiquidTemplate except that it automatically sets the response as text/html.

Example:

open Giraffe
open Giraffe.DotLiquid

type Person =
    {
        FirstName : string
        LastName  : string
    }

let fooBar = { FirstName = "Foo"; LastName = "Bar" }

let app =
    choose [
        route  "/foo" >=> dotLiquidHtmlTemplate "templates/person.html" fooBar
    ]

Samples

Please find a fully functioning sample application under ./samples/GiraffeDotLiquidSample/.

Nightly builds and NuGet feed

All official release packages are published to the official and public NuGet feed.

Nightly builds (builds from the develop branch) produce unofficial pre-release packages which can be pulled from the project's NuGet feed on GitHub.

These packages are being tagged with the Workflow's run number as the package version.

All other builds, such as builds triggered by pull requests produce a NuGet package which can be downloaded as an artifact from the individual GitHub action.

More information

For more information about Giraffe, how to set up a development environment, contribution guidelines and more please visit the main documentation page.

License

Apache 2.0

giraffe.dotliquid's People

Contributors

dustinmoris avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

giraffe.dotliquid's Issues

Dependency to giraffe 4

Hello, It seems Giraffe DotLiquid has a hard dependency on giraffe 4.x. An upgrade would be great.

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.