e2h
e2h 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 suspicious characters within HTML content. This module is suitable for developers who need to programmatically generate HTML documents or elements in their Erlang applications.
Installation
Package can be installed by adding e2h to your list of dependencies:
Rebar3
{deps, [{e2h, "0.2.0"}]}.Mix
defp deps do
[{:e2h, "~> 0.2.0"}]
endExample
UserStatus = <<"busy">>,
UserProfileImage = <<"https://example.com/image.jpeg">>,
UserName = <<"adam">>,
UserBio = <<"some nonsense">>,
Document = [
{'div', [{class, <<"user">>}, {status, UserStatus}], [
{img, [{href, UserProfileImage}]},
{'div', [], [
{h1, [], [UserName]},
{p, [], [UserBio]}
]}
]}
],
e2h:render(Document).
% <!DOCTYPE html>
% <div class="user" status="busy"><img href="https://example.com/image.jpeg" /><div><h1>adam</h1><p>some nonsense</p></div></div>Documentation
Please consult the HexDocs for documentation.
License
e2h is licensed under the MIT license.