Yzl (pronounced easel) stands for YAML Zero-Language. It's an experimental pragmatic template-less approach to YAML generation powered by F#. It provides primitives (functions and operators) for string-less (almost) idiomatic YAML generation. It's an alternative to YAML templating engines. Yzl supports most common YAML features although it doesn't have an ambition to fully support the YAML specification. So if any feature is missing - open a GitHub issue.
- Reference the Yzl NuGet package
- Start writing your YAML
open Yzl.Core let test (value:bool) = "test" .= value [ test true ] |> Yzl.render
[ "a"; "b"; "c" ] |> Yzl.render
- a - b - c
let rootMap (value: Yzl.NamedNode list) = "rootMap" .= value [ rootMap [ test false ] ] |> Yzl.render
rootMap: test: false
[ "number" .= 5 "sequence" .= [ 938 48 1 ] "otherKey" .= [ "float" .= 1.56 ] ] |> Yzl.render
number: 5 sequence: - 938 - 48 - 1 otherKey: float: 1.56
Yzl supports different kinds of YAML strings via a set of operators.
The convention here is that all the special kinds of strings are prefixed with
let myString (value:Yzl.Str) = "myString" .= value [ myString !|- """ this is some special string with weird indentation """ ] |> Yzl.render
myString: |- this is some special string with weird indentation
Yzl heavily exploits F# lists which means it is very easy to use list comprehension expressions to dynamically build YAML.
let map = [ "one", 1 "two", 2 "three", 3 ] [ for (k, v) in map do k .= v ] |> Yzl.render
one: 1 two: 2 three: 3
It is an alpha feature where Yzl elements can be generated from a JSON schema so no manual map functions need to be created.
Additional bindings can be generated with Yzl.Bindings.Gen.