Arizona - a web framework for Erlang/OTP

Hi everyone! :waving_hand:

I’m excited to share the latest Arizona updates.

TL;DR

  • Erlang Term Templates: Write templates as pure Erlang terms with full editor support and compile-time validation
  • Markdown Support: Full GitHub Flavored Markdown with Arizona template syntax integration
  • Component Lifecycle: Proper cleanup with unmount/1 callbacks for timers, PubSub, and resources
  • File-Based Templates: Load templates from files with compile-time optimization
  • Template Flexibility: Mix Erlang terms, HTML, Markdown, and file-based templates freely
  • Many bug fixes: Enhanced stability, performance, and error messages

What’s New

1. Erlang Term-Based Template Syntax

I’ve added a new way to write templates using pure Erlang terms, giving you full editor support, syntax highlighting, and compile-time validation:

arizona_template:from_erl([
    {'div', [{class, ~"container"}], [
        {h1, [], [arizona_template:get_binding(title, Bindings)]}
    ]}
])

2. GitHub Flavored Markdown Templates

Content-driven applications can now use Markdown with full Arizona template syntax and full GFM support (tables, autolinks, strikethrough, task lists):

arizona_template:from_markdown(~"""
# Arizona Framework

Welcome **{arizona_template:get_binding(user, Bindings)}**!

{% This is a template comment }

{arizona_template:render_stateful(comment_section, #{
    id => ~"comments",
    post_id => arizona_template:get_binding(id, Bindings)
})}

- Item 1
- Item 2
""")

3. Stateful Component Lifecycle Management

Components now support proper cleanup with unmount/1 callbacks:

-module(timer_component).
-behaviour(arizona_stateful).
-export([mount/1, render/1, unmount/1]).

mount(Bindings) ->
    {ok, TimerRef} = timer:send_interval(1000, tick),
    arizona_live:is_connected(self()) andalso arizona_pubsub:join(~"updates", self()),
    arizona_stateful:new(?MODULE, Bindings#{timer_ref => TimerRef}).

% Automatic cleanup when component is removed
unmount(State) ->
    TimerRef = arizona_stateful:get_binding(timer_ref, State),
    timer:cancel(TimerRef),
    arizona_pubsub:leave(~"updates", self()),
    ok.

4. File-Based Template Compilation

Templates can now be loaded from files with compile-time optimization:

% HTML from files
arizona_template:from_html({file, "templates/user.html"})
arizona_template:from_html({priv_file, myapp, "templates/user.html"})

% Markdown from files
arizona_template:from_markdown({file, "content/blog-post.md"})
arizona_template:from_markdown({priv_file, myapp, "content/post.md"})

Parse transforms optimize file-based templates at compile time just like inline templates.

Bug Fixes & Improvements

This release includes numerous bug fixes and improvements.


I’d love to hear your thoughts! Have you tried Arizona? What would you like to see next? Let me know in the replies.

Happy coding! :cactus:

Notes:

  • Arizona requires Erlang/OTP 28+
  • v0.1.0 coming soon on Hex
  • These changes introduced breaking changes that are not reflected in rebar3_arizona and other Arizona Framework repositories (I’ll be updating them)