Mustache

template

defn

(λ [&String, (Ref (Map String Mustache))] String)

                    (template s values)
                

templates a Mustache-formatted string s using the map values.

The map must be from String to Mustache (can be either Str or Lambda).

Example call:

(Mustache.template
  "this is a super {{ adjective }} library"
  &{@"adjective" (Mustache.Str @"cool")}
)

The Str constructor represents a simple string body. It is treated as falsy when it is empty, and truthy otherwise.

The Lambda constructor represents a function that gets invoked on the string body of the section. Check out the section entitled “Lambdas” in the official Mustache documentation. It gets always treated as truthy.

The Lst constructor is currently missing, because types cannot be recursive. Bummer. This will get fixed in a later version of Carp.

All escaped names will be trimmed, i.e. {{ thing }} will be looked up as "thing" in the map. Furthermore, opening and closing sections need to be formatted the same, i.e. {{/thing}} is not a section close for {{^ thing }}. Please be consistent in your formatting.