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() = [{binary(), binary()} | binary()]
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() = [{binary(), attributes(), elements()} | {binary(), 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">>}]} ]} ].
escape/1 | Escapes dangerous HTML characters within a binary data input. |
render_fragment/1 | Renders a list of structure into a binary representation of an HTML document. |
render_html/1 | Similar to render_fragment/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_fragment(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_fragment/1
, with a DOCTYPE declaration.
Generated by EDoc