Module mustache

Mustach template engine for Erlang/OTP.

Copyright © 2015 Hinagiku Soranoba All Rights Reserved.

Description

Mustach template engine for Erlang/OTP.

Data Types

assoc_data()

assoc_data() = [{atom(), data_value()}] | [{binary(), data_value()}] | [{string(), data_value()}]

data()

data() = assoc_data()

data_value()

data_value() = data() | iodata() | number() | atom() | fun((data(), function()) -> iodata())

Function is intended to support a lambda expression.

option()

option() = {key_type, atom | binary | string}

- key_type: Specify the type of the key in data/0. Default value is string.

template()

abstract datatype: template()

Function Index

compile/2Equivalent to compile(Template, Data, []).
compile/3Embed the data in the template.
parse_binary/1Create a template/0 from a binary.
parse_file/1Create a template/0 from a file.
render/2Equivalent to render(Bin, Data, []).
render/3Equivalent to compile(parse_binary(Bin), Data, Options).

Function Details

compile/2

compile(Template::template(), Data::data()) -> binary()

Equivalent to compile(Template, Data, []).

compile/3

compile(Mustache::template(), Data::data(), Options::[option()]) -> binary()

Embed the data in the template.

  1> Template = mustache:parse_binary(<<"{{name}}">>).
  2> mustache:compile(Template, #{"name" => "Alice"}).
  <<"Alice">>
Data support assoc list or maps (OTP17 or later).
All key in assoc list or maps must be same type.

parse_binary/1

parse_binary(Bin::binary()) -> template()

Create a template/0 from a binary.

parse_file/1

parse_file(Filename::file:filename_all()) -> template()

Create a template/0 from a file.

render/2

render(Bin::binary(), Data::data()) -> binary()

Equivalent to render(Bin, Data, []).

See also: compile/2, parse_binary/1, parse_file/1, render/2.

render/3

render(Bin::binary(), Data::data(), Options::[option()]) -> binary()

Equivalent to compile(parse_binary(Bin), Data, Options).


Generated by EDoc