e2h
(Erlang to HTML) is an Erlang module designed to generate HTML content within the Erlang.
It provides functions for encoding HTML elements and attributes, as well as escaping dangerous characters within HTML content.
This module is suitable for developers who need to programmatically generate HTML documents or elements in their Erlang applications.
Package can be installed by adding e2h
to your list of dependencies:
{deps, [{e2h, "0.4.2"}]}.
Here's a simple example of how to use e2h
to generate an HTML document in Erlang:
UserStatus = <<"busy">>,
UserProfileImage = <<"https://example.com/image.jpeg">>,
UserName = <<"bob">>,
UserJob = <<"data scientist">>,
Document = [
{<<"div">>, [{<<"class">>, <<"user">>}, {<<"status">>, UserStatus}], [
{<<"img">>, [{<<"href">>, UserProfileImage}]},
{<<"div">>, [], [
{<<"h1">>, [], [UserName]},
{<<"p">>, [], [UserJob]}
]}
]}
],
e2h:render_fragment(Document).
% (output is manually formatted for readme)
%
% <div class="user" status="busy">
% <img href="https://example.com/image.jpeg" />
% <div>
% <h1>bob</h1>
% <p>data scientist</p>
% </div>
% </div>
For documentation, please refer to the official HexDocs page.
e2h
is licensed under the MIT license.