-module(elements). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]). -export([attr/2, text/1, element/3, element_self_closing/2, html/2, head/2, title/1, meta/1, body/2, p/2, h1/2, h2/2, h3/2, h4/2, h5/2, a/2, span/2, 'div'/2]). -export_type([html_attribute/0, html_element/0]). -type html_attribute() :: {html_attribute, binary(), binary()}. -type html_element() :: {html_element, binary(), list(html_attribute()), list(html_element())} | {text, binary()}. -spec attr(binary(), binary()) -> html_attribute(). attr(Key, Value) -> {html_attribute, Key, Value}. -spec text(binary()) -> html_element(). text(Value) -> {text, Value}. -spec element(binary(), list(html_attribute()), list(html_element())) -> html_element(). element(Tag, Attrs, Children) -> {html_element, Tag, Attrs, Children}. -spec element_self_closing(binary(), list(html_attribute())) -> html_element(). element_self_closing(Tag, Attrs) -> element(Tag, Attrs, []). -spec html(list(html_attribute()), list(html_element())) -> html_element(). html(Attrs, Children) -> element(<<"html"/utf8>>, Attrs, Children). -spec head(list(html_attribute()), list(html_element())) -> html_element(). head(Attrs, Children) -> element(<<"head"/utf8>>, Attrs, Children). -spec title(binary()) -> html_element(). title(Title) -> element(<<"title"/utf8>>, [], [text(Title)]). -spec meta(list(html_attribute())) -> html_element(). meta(Attrs) -> element_self_closing(<<"meta"/utf8>>, Attrs). -spec body(list(html_attribute()), list(html_element())) -> html_element(). body(Attrs, Children) -> element(<<"body"/utf8>>, Attrs, Children). -spec p(list(html_attribute()), list(html_element())) -> html_element(). p(Attrs, Children) -> element(<<"p"/utf8>>, Attrs, Children). -spec h1(list(html_attribute()), list(html_element())) -> html_element(). h1(Attrs, Children) -> element(<<"h1"/utf8>>, Attrs, Children). -spec h2(list(html_attribute()), list(html_element())) -> html_element(). h2(Attrs, Children) -> element(<<"h2"/utf8>>, Attrs, Children). -spec h3(list(html_attribute()), list(html_element())) -> html_element(). h3(Attrs, Children) -> element(<<"h3"/utf8>>, Attrs, Children). -spec h4(list(html_attribute()), list(html_element())) -> html_element(). h4(Attrs, Children) -> element(<<"h4"/utf8>>, Attrs, Children). -spec h5(list(html_attribute()), list(html_element())) -> html_element(). h5(Attrs, Children) -> element(<<"h5"/utf8>>, Attrs, Children). -spec a(list(html_attribute()), list(html_element())) -> html_element(). a(Attrs, Children) -> element(<<"a"/utf8>>, Attrs, Children). -spec span(list(html_attribute()), list(html_element())) -> html_element(). span(Attrs, Children) -> element(<<"span"/utf8>>, Attrs, Children). -spec 'div'(list(html_attribute()), list(html_element())) -> html_element(). 'div'(Attrs, Children) -> element(<<"div"/utf8>>, Attrs, Children).