Authors: bunopnu.
HTML generator for Erlang ecosystem.
e2h
is an Erlang module designed to generate HTML within the Erlang
ecosystem, allowing Erlang developers to efficiently create HTML documents
and elements from structured data.
attributes() = [{key(), binary()} | key()]
Represents a list of HTML attribute-value pairs.
Attributes = [{<<"type">>, <<"password">>}, {id, <<"my-element">>}, disabled]. % Represents attributes like: type="password" id="my-element" disabled
elements() = [{key(), attributes(), elements()} | {key(), attributes()} | binary()]
Represents structured HTML elements or raw content.
Elements = [ {<<"div">>, [{<<"class">>, <<"container">>}], [ {<<"p">>, [], [<<"This is a paragraph.">>]}, {<<"a">>, [{<<"href">>, <<"#">>}], [<<"Click me">>]}, {img, [{src, <<"https://example.com/image.png">>}]} ]} ].
key() = binary() | atom()
Represents keys that can be either binary data or atoms.
escape/1 | Escapes dangerous HTML characters within a binary data input. |
render/1 | Renders a list of structure into a binary representation of an HTML document. |
render_html/1 | Similar to render/1 , with a DOCTYPE declaration. |
escape(Data::binary()) -> binary()
Escapes dangerous HTML characters within a binary data input.
Data
- The binary data to be escaped.
The escaped binary data.
Unescaped = <<"Suspicious <script>alert(1)</script> document!">>, Escaped = e2h:escape(Unescaped). % <<"Suspicious <script>alert(1)</script> document!">>
render(Elements::elements()) -> binary()
Renders a list of structure into a binary representation of an HTML document.
Elements
- A list of structure, conforming to the elements()
type.
render_html(Elements::elements()) -> binary()
Similar to render/1
, with a DOCTYPE declaration.
Generated by EDoc