Framework

BeamAI Render · Template and Markdown rendering for Erlang

Templates compile to .erl files at build time by a rebar3 plugin, so rendering at runtime is one ordinary function call: no processes, no ETS tables, no lookups. Static template text goes into the module's literal pool and is shared across processes by reference.

Markdown renders at runtime under the same discipline: the pipeline is a plain map and nothing is cached. The library and its test suite depend only on OTP.

Templates compile to modules; rendering is a function call

rebar.config and Markdown rendering
%% rebar.config: both template engines side by side
{provider_hooks, [{pre, [{compile, mustache}, {compile, jinja}]}]}.
{mustache_opts, [{views, "views"}, {prefix, "view_"}]}.
{jinja_opts,    [{views, "views"}, {suffix, ".j2"}, {prefix, "j2_"}]}.

%% Markdown
beamai_markdown:to_html(~"Hello *world*!").
%% => <<"<p>Hello <em>world</em>!</p>\n">>

P = beamai_markdown:pipeline([pipe_tables, task_lists, footnotes]),
beamai_markdown:to_html(Text, P).

Features

What it can do

  • Mustache

    Passes all 136 cases of the six mandatory modules in the official mustache spec; .mustache files compile into modules with the view_ prefix.

  • Jinja2

    Supports include, extends, macro, import, and |safe; the consistency baseline is 520 fixtures generated by CPython jinja2 3.1. Shares one views directory with Mustache.

  • Markdown

    Ported from markdig via cl-markding: passes all 652 CommonMark 0.31.2 cases and 649 byte-exact roundtrip cases; 30 extensions (pipe and grid tables, task lists, footnotes, math, emoji, SmartyPants, alerts, and more).

  • Four output formats

    HTML, plain text, normalized Markdown, and verbatim roundtrip renderers.

  • Compile-time folding

    beamai_markdown_transform folds literal Markdown calls or -markdown_document files into HTML at compile time — zero runtime cost.

  • Zero dependencies

    Library and test suite depend only on OTP; every generated file records which engine produced it, and each provider reclaims only its own orphan files.

Specifications

Technical specifications

RuntimeErlang/OTP, rebar3 plugins (rebar3 mustache / rebar3 jinja)
Version0.6.0
DependenciesOTP only
LicenseApache License 2.0

FAQ

You might be wondering

Mustache or Jinja2?

They are siblings — one project can use both. Mustache is simple and logic-free; Jinja2 adds lexical scoping, inheritance, macros, and filters for complex pages. Watch the differences in truthiness and escaping — the README has a comparison table.

What is the runtime overhead?

Templates compile to Erlang modules at build time; rendering is one ordinary function call with no processes and no ETS. Static text shares the literal pool across processes.

What is the license?

Apache License 2.0, fine for commercial projects.

Open source

Apache 2.0 open source

The engine, tests, benchmarks, and design docs are all in the repository — read them, change them, file issues.

Related framework

aihtml · Web pages written in Erlang functions

Assemble pages from Erlang functions with complete server-side HTML; clicks are answered statelessly by Erlang functions and server pushes ride SSE. 112 components, four theme axes, SEO-friendly.