lukewestby/elm-template/1.0.1

NOTE: this package is not compatible with Elm 0.19.1

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"
andValue : Template record -> (record -> String) -> Template record

Attach a record accessor to a template inline

template "my string " `andValue` .hello
andString : Template record -> String -> Template record

Attach a string to a template inline

template "my string " `andValue` .hello `andString` " another string"

rendering

render : Template record -> record -> String

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

render
  (template "my string " `andValue` .hello)
  ({ hello = "world" })