Skip to content

Flxble.Templating

cannorin edited this page Jan 16, 2019 · 7 revisions

Flxble.Templating is an end-user (sandboxed) templating engine built for flxble.

However, you can use it as a separate templating library, and it is the best templating library for F#!

Features

Optimized for F#

Flxble.Templating is written entirely in F# and can be easily used from F# too.

The common workflow is:

open Flxble.Templating
open System.Text

let context =
  TemplateContext.create
    CultureInfo.InvariantCulture
    (sprintf "<!-- %s -->") // comment out error messages for HTML

let template = Template.loadFile Encoding.UTF8 "test.html"

let result = template |> Template.renderToString context

F#-ish scripting language

Have you tired of those fake "functional" scripting languages?

Flxble.Templating has real pipe operators |>, real function compositions >>, real lambda abstractions fun x -> .., and real map/filter/fold functions which utilize them.

See Flxble.Templating: The language for details.

Completely thread-safe, good for parallelism

Unlike any other .NET templating engines, Flxble.Templating does not use mutable states for evaluation context. Instead, it uses persistent data structures which are completely thread-safe.

So, you can safely run arbitrary many numbers of render processes at the same time, which can drastically reduce the execution time!

Very fast!

Flxble.Templating is 1.2x to 7.3x times faster compared to the famous .NET end-user templating engines. Since it is completely thread-safe (unlike most of the other ones), it can be even faster with parallelism!

See Flxble.Templating: Benchmarks for details.

Getting Started

It supports netstandard1.6 or later and can be installed from NuGet:

PM> Install-Package Flxble.Templating
$ dotnet add package Flxble.Templating

Sidebar:

Flxble.Templating:

Clone this wiki locally