Platem

Platem is a templating engine made for Elixir.

Installation

If available in Hex, the package can be installed by adding platem to your list of dependencies in mix.exs:

def deps do
  [
    {:platem, "~> 0.1.0"}
  ]
end

After you have added platem to your mix file, and you have installed it, you have to paste the following code snippet into your supervision tree:

{DynamicSupervisor, name: Platem, strategy: :one_for_one}

After you have done that you are good to go.

Usage

To use platem, you have to define a template first. You can do it in the following way:

template = %Platem.Template{
  template: "some {{type}}",
  fields: [
    %Platem.Field{name: "type", default: "markdown"}
  ]
  clause: {"{{", "}}"}
}

After we have done that we can define the values. If a value is left blank, the engine will use the default value.

values = [
  %Platem.Value{name: "type", value: "html"}
]

Finally we can call the populate function.

Platem.populate(template, values)

Which will give us the following:

%Platem.Template{
  template: "some html",
  fields: [
    %Platem.Field{name: "type", default: "markdown"}
  ]
  clause: {"{{", "}}"}
}

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/platem.