lukewestby / elm-template / Template

Type-safe string templating

types


type alias Template a =
List (Component a)

A list of the components of a template

construction

template : String -> Template record

Create an initial template starting with the given string

template "my string "

withValue : (record -> String) -> Template record -> Template record

Attach a record accessor to a template

template "my string "
    |> withValue .hello

withString : String -> Template record -> Template record

Attach a string to a template

template "my string "
    |> withValue .hello
    |> withString " another string"

rendering

render : record -> Template record -> String

Walks through a template's components and renders them to a single string

template "my string "
    |> withValue .hello
    |> withString " another string"
    |> render { hello = "world" }