Packages

A Gleam library for generating HTML

Current section

Files

Jump to
htmz src htmz.erl
Raw

src/htmz.erl

-module(htmz).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-export([escape/1, children/2, child/2, remove_attr/2, attr/3, nothing/1, text/2, accept/2, accept_charset/2, accesskey/2, action/2, alt/2, async_attr/2, autocapitalize/2, autofocus/2, autocomplete/2, charset/2, checked/2, class/2, cols/2, columngap/2, colspan/2, content/2, contenteditable/2, contextmenu/2, controls/2, coords/2, crossorigin/2, data/3, datetime/2, defer/1, dir/2, dirname/2, disabled/1, download/2, draggable/2, dropzone/2, enctype/2, enterkeyhint/2, for/2, formaction/2, formenctype/2, formmethod/2, formnovalidate/2, formtarget/2, frameborder/2, headers/2, height/2, hidden/2, high/2, href/2, hreflang/2, http_equiv/2, id/2, inputmode/2, integrity/2, is/2, ismap/2, kind/2, label/2, lang/2, language/2, list/2, loop_attr/2, low/2, max/2, maxlength/2, method/2, min/2, minlength/2, multiple/2, name/2, novalidate/2, on/3, open/2, pattern/2, placeholder/2, poster/2, preload/2, readonly/2, rel/2, required/1, reversed/2, rows/2, rowspan/2, sandbox/2, scope/2, selected/1, shape/2, size/2, sizes/2, slot/2, spellcheck/2, src/2, srcdoc/2, srclang/2, start/2, step/2, style/2, tabindex/2, target/2, title/2, translate/2, type_/2, usemap/2, value/2, width/2, wrap/2, hx_boost/2, hx_confirm/2, hx_delete/2, hx_disabled_elt/2, hx_sync/2, hx_disinherit/2, hx_encoding/2, hx_ext/2, hx_get/2, hx_headers/2, hx_history/2, hx_history_elt/2, hx_include/2, hx_indicator/2, hx_on/3, hx_params/2, hx_post/2, hx_put/2, hx_patch/2, hx_push_url/2, hx_select/2, hx_select_oob/2, hx_swap/2, hx_swap_oob/2, hx_target/2, hx_trigger/2, hx_vals/2, x_data/2, x_init/2, x_show/2, x_bind/3, x_on/3, x_text/2, x_html/2, x_model/2, x_modelable/2, x_for/2, x_transition/1, x_transition_a/3, x_effect/2, x_ignore/2, x_ref/2, x_cloak/2, x_teleport/2, x_if/2, x_id/2, to_string/1]).
-export_type([attr/0, htmz/0]).
-type attr() :: {attr, binary(), binary()}.
-type htmz() :: {el, binary(), list(attr()), list(htmz())} |
{z, binary()} |
{text, binary()} |
nothing |
html |
head |
title |
body |
'div' |
form |
label |
input |
a |
link |
meta |
abbr |
address |
article |
aside |
audio |
b |
bdi |
bdo |
blockquote |
br |
button |
canvas |
caption |
cite |
code |
col |
colgroup |
data |
datalist |
dd |
del |
details |
dfn |
dialog |
dl |
dt |
em |
embed |
fieldset |
figcaption |
figure |
footer |
h1 |
h2 |
h3 |
h4 |
h5 |
h6 |
header |
hr |
i |
iframe |
img |
ins |
kbd |
legend |
li |
main |
mark |
menu |
menuitem |
meter |
nav |
noscript |
object |
ol |
optgroup |
option |
output |
p |
param |
picture |
pre |
progress |
q |
rp |
rt |
ruby |
s |
samp |
script |
section |
select |
slot |
small |
source |
span |
strong |
sub |
summary |
sup |
table |
tbody |
td |
template |
textarea |
tfoot |
th |
thead |
time |
tr |
track |
u |
ul |
var |
video |
wbr.
-spec do_escape(binary(), binary()) -> binary().
do_escape(Escaped, Content) ->
case gleam@string:pop_grapheme(Content) of
{ok, {<<"<"/utf8>>, Xs}} ->
do_escape(<<Escaped/binary, "&lt;"/utf8>>, Xs);
{ok, {<<">"/utf8>>, Xs@1}} ->
do_escape(<<Escaped/binary, "&gt;"/utf8>>, Xs@1);
{ok, {<<"&"/utf8>>, Xs@2}} ->
do_escape(<<Escaped/binary, "&amp;"/utf8>>, Xs@2);
{ok, {X, Xs@3}} ->
do_escape(<<Escaped/binary, X/binary>>, Xs@3);
{error, _} ->
<<Escaped/binary, Content/binary>>
end.
-spec escape(binary()) -> binary().
escape(Content) ->
do_escape(<<""/utf8>>, Content).
-spec attrs_to_string(list(attr())) -> binary().
attrs_to_string(Attrs) ->
Str = begin
_pipe = Attrs,
_pipe@1 = gleam@list:map(
_pipe,
fun(Attr) ->
Name = gleam@string:lowercase(erlang:element(2, Attr)),
case Name of
<<""/utf8>> ->
<<""/utf8>>;
_ ->
case erlang:element(3, Attr) of
<<""/utf8>> ->
Name;
_ ->
<<<<<<Name/binary, "=\""/utf8>>/binary,
(escape(erlang:element(3, Attr)))/binary>>/binary,
"\""/utf8>>
end
end
end
),
gleam@string:join(_pipe@1, <<" "/utf8>>)
end,
case Str of
<<""/utf8>> ->
<<""/utf8>>;
_ ->
<<" "/utf8, Str/binary>>
end.
-spec to_tuple(htmz()) -> {binary(), list(attr()), list(htmz())}.
to_tuple(El) ->
case El of
{el, Tag, Attrs, Children} ->
{Tag, Attrs, Children};
{z, Css_selector} ->
_assert_subject = htmz@selector_parser:parse_css_selector(
Css_selector
),
{some, {parse_result, Tag@1, Attrs@1}} = case _assert_subject of
{some, {parse_result, _, _}} -> _assert_subject;
_assert_fail ->
erlang:error(#{gleam_error => let_assert,
message => <<"Assertion pattern match failed"/utf8>>,
value => _assert_fail,
module => <<"htmz"/utf8>>,
function => <<"to_tuple"/utf8>>,
line => 199})
end,
Attrs@2 = gleam@list:map(
Attrs@1,
fun(T) -> {attr, erlang:element(1, T), erlang:element(2, T)} end
),
{Tag@1, Attrs@2, []};
{text, _} ->
{<<""/utf8>>, [], []};
nothing ->
{<<""/utf8>>, [], []};
html ->
{<<"html"/utf8>>, [], []};
head ->
{<<"head"/utf8>>, [], []};
title ->
{<<"title"/utf8>>, [], []};
body ->
{<<"body"/utf8>>, [], []};
'div' ->
{<<"div"/utf8>>, [], []};
form ->
{<<"form"/utf8>>, [], []};
label ->
{<<"label"/utf8>>, [], []};
input ->
{<<"input"/utf8>>, [], []};
a ->
{<<"a"/utf8>>, [], []};
link ->
{<<"link"/utf8>>, [], []};
meta ->
{<<"meta"/utf8>>, [], []};
abbr ->
{<<"abbr"/utf8>>, [], []};
address ->
{<<"address"/utf8>>, [], []};
article ->
{<<"article"/utf8>>, [], []};
aside ->
{<<"aside"/utf8>>, [], []};
audio ->
{<<"audio"/utf8>>, [], []};
b ->
{<<"b"/utf8>>, [], []};
bdi ->
{<<"bdi"/utf8>>, [], []};
bdo ->
{<<"bdo"/utf8>>, [], []};
blockquote ->
{<<"blockquote"/utf8>>, [], []};
br ->
{<<"br"/utf8>>, [], []};
button ->
{<<"button"/utf8>>, [], []};
canvas ->
{<<"canvas"/utf8>>, [], []};
caption ->
{<<"caption"/utf8>>, [], []};
cite ->
{<<"cite"/utf8>>, [], []};
code ->
{<<"code"/utf8>>, [], []};
col ->
{<<"col"/utf8>>, [], []};
colgroup ->
{<<"colgroup"/utf8>>, [], []};
data ->
{<<"data"/utf8>>, [], []};
datalist ->
{<<"datalist"/utf8>>, [], []};
dd ->
{<<"dd"/utf8>>, [], []};
del ->
{<<"del"/utf8>>, [], []};
details ->
{<<"details"/utf8>>, [], []};
dfn ->
{<<"dfn"/utf8>>, [], []};
dialog ->
{<<"dialog"/utf8>>, [], []};
dl ->
{<<"dl"/utf8>>, [], []};
dt ->
{<<"dt"/utf8>>, [], []};
em ->
{<<"em"/utf8>>, [], []};
embed ->
{<<"embed"/utf8>>, [], []};
fieldset ->
{<<"fieldset"/utf8>>, [], []};
figcaption ->
{<<"figcaption"/utf8>>, [], []};
figure ->
{<<"figure"/utf8>>, [], []};
footer ->
{<<"footer"/utf8>>, [], []};
h1 ->
{<<"h1"/utf8>>, [], []};
h2 ->
{<<"h2"/utf8>>, [], []};
h3 ->
{<<"h3"/utf8>>, [], []};
h4 ->
{<<"h4"/utf8>>, [], []};
h5 ->
{<<"h5"/utf8>>, [], []};
h6 ->
{<<"h6"/utf8>>, [], []};
header ->
{<<"header"/utf8>>, [], []};
hr ->
{<<"hr"/utf8>>, [], []};
i ->
{<<"i"/utf8>>, [], []};
iframe ->
{<<"iframe"/utf8>>, [], []};
img ->
{<<"img"/utf8>>, [], []};
ins ->
{<<"ins"/utf8>>, [], []};
kbd ->
{<<"kbd"/utf8>>, [], []};
legend ->
{<<"legend"/utf8>>, [], []};
li ->
{<<"li"/utf8>>, [], []};
main ->
{<<"main"/utf8>>, [], []};
mark ->
{<<"mark"/utf8>>, [], []};
menu ->
{<<"menu"/utf8>>, [], []};
menuitem ->
{<<"menuitem"/utf8>>, [], []};
meter ->
{<<"meter"/utf8>>, [], []};
nav ->
{<<"nav"/utf8>>, [], []};
noscript ->
{<<"noscript"/utf8>>, [], []};
object ->
{<<"object"/utf8>>, [], []};
ol ->
{<<"ol"/utf8>>, [], []};
optgroup ->
{<<"optgroup"/utf8>>, [], []};
option ->
{<<"option"/utf8>>, [], []};
output ->
{<<"output"/utf8>>, [], []};
p ->
{<<"p"/utf8>>, [], []};
param ->
{<<"param"/utf8>>, [], []};
picture ->
{<<"picture"/utf8>>, [], []};
pre ->
{<<"pre"/utf8>>, [], []};
progress ->
{<<"progress"/utf8>>, [], []};
q ->
{<<"q"/utf8>>, [], []};
rp ->
{<<"rp"/utf8>>, [], []};
rt ->
{<<"rt"/utf8>>, [], []};
ruby ->
{<<"ruby"/utf8>>, [], []};
s ->
{<<"s"/utf8>>, [], []};
samp ->
{<<"samp"/utf8>>, [], []};
script ->
{<<"script"/utf8>>, [], []};
section ->
{<<"section"/utf8>>, [], []};
select ->
{<<"select"/utf8>>, [], []};
slot ->
{<<"slot"/utf8>>, [], []};
small ->
{<<"small"/utf8>>, [], []};
source ->
{<<"source"/utf8>>, [], []};
span ->
{<<"span"/utf8>>, [], []};
strong ->
{<<"strong"/utf8>>, [], []};
sub ->
{<<"sub"/utf8>>, [], []};
summary ->
{<<"summary"/utf8>>, [], []};
sup ->
{<<"sup"/utf8>>, [], []};
table ->
{<<"table"/utf8>>, [], []};
tbody ->
{<<"tbody"/utf8>>, [], []};
td ->
{<<"td"/utf8>>, [], []};
template ->
{<<"template"/utf8>>, [], []};
textarea ->
{<<"textarea"/utf8>>, [], []};
tfoot ->
{<<"tfoot"/utf8>>, [], []};
th ->
{<<"th"/utf8>>, [], []};
thead ->
{<<"thead"/utf8>>, [], []};
time ->
{<<"time"/utf8>>, [], []};
tr ->
{<<"tr"/utf8>>, [], []};
track ->
{<<"track"/utf8>>, [], []};
u ->
{<<"u"/utf8>>, [], []};
ul ->
{<<"ul"/utf8>>, [], []};
var ->
{<<"var"/utf8>>, [], []};
video ->
{<<"video"/utf8>>, [], []};
wbr ->
{<<"wbr"/utf8>>, [], []}
end.
-spec children(htmz(), list(htmz())) -> htmz().
children(El, Children) ->
{Tag, Attrs, _} = to_tuple(El),
{el, Tag, Attrs, Children}.
-spec child(htmz(), htmz()) -> htmz().
child(El, Child) ->
{Tag, Attrs, Children} = to_tuple(El),
{el, Tag, Attrs, [Child | Children]}.
-spec remove_attr(htmz(), binary()) -> htmz().
remove_attr(El, Attr_name) ->
{Tag, Attrs, Children} = to_tuple(El),
Attrs@1 = begin
_pipe = Attrs,
gleam@list:filter(
_pipe,
fun(Attr) -> erlang:element(2, Attr) /= Attr_name end
)
end,
{el, Tag, Attrs@1, Children}.
-spec attr(htmz(), binary(), binary()) -> htmz().
attr(El, Attr_name, Attr_value) ->
{Tag, Attrs, Children} = begin
_pipe = El,
_pipe@1 = remove_attr(_pipe, Attr_name),
to_tuple(_pipe@1)
end,
Attrs@1 = [{attr, Attr_name, Attr_value} | Attrs],
{el, Tag, Attrs@1, Children}.
-spec nothing(htmz()) -> htmz().
nothing(El) ->
attr(El, <<""/utf8>>, <<""/utf8>>).
-spec text(htmz(), binary()) -> htmz().
text(El, Text) ->
child(El, {text, Text}).
-spec accept(htmz(), binary()) -> htmz().
accept(El, Value) ->
attr(El, <<"accept"/utf8>>, Value).
-spec accept_charset(htmz(), binary()) -> htmz().
accept_charset(El, Value) ->
attr(El, <<"acceptCharset"/utf8>>, Value).
-spec accesskey(htmz(), binary()) -> htmz().
accesskey(El, Value) ->
attr(El, <<"accesskey"/utf8>>, Value).
-spec action(htmz(), binary()) -> htmz().
action(El, Value) ->
attr(El, <<"action"/utf8>>, Value).
-spec alt(htmz(), binary()) -> htmz().
alt(El, Value) ->
attr(El, <<"alt"/utf8>>, Value).
-spec async_attr(htmz(), binary()) -> htmz().
async_attr(El, Value) ->
attr(El, <<"async"/utf8>>, Value).
-spec autocapitalize(htmz(), binary()) -> htmz().
autocapitalize(El, Value) ->
attr(El, <<"autocapitalize"/utf8>>, Value).
-spec autofocus(htmz(), binary()) -> htmz().
autofocus(El, Value) ->
attr(El, <<"autofocus"/utf8>>, Value).
-spec autocomplete(htmz(), binary()) -> htmz().
autocomplete(El, Value) ->
attr(El, <<"autocomplete"/utf8>>, Value).
-spec charset(htmz(), binary()) -> htmz().
charset(El, Value) ->
attr(El, <<"charset"/utf8>>, Value).
-spec checked(htmz(), binary()) -> htmz().
checked(El, Value) ->
attr(El, <<"checked"/utf8>>, Value).
-spec class(htmz(), binary()) -> htmz().
class(El, Value) ->
attr(El, <<"class"/utf8>>, Value).
-spec cols(htmz(), binary()) -> htmz().
cols(El, Value) ->
attr(El, <<"cols"/utf8>>, Value).
-spec columngap(htmz(), binary()) -> htmz().
columngap(El, Value) ->
attr(El, <<"columngap"/utf8>>, Value).
-spec colspan(htmz(), binary()) -> htmz().
colspan(El, Value) ->
attr(El, <<"colspan"/utf8>>, Value).
-spec content(htmz(), binary()) -> htmz().
content(El, Value) ->
attr(El, <<"content"/utf8>>, Value).
-spec contenteditable(htmz(), binary()) -> htmz().
contenteditable(El, Value) ->
attr(El, <<"contenteditable"/utf8>>, Value).
-spec contextmenu(htmz(), binary()) -> htmz().
contextmenu(El, Value) ->
attr(El, <<"contextmenu"/utf8>>, Value).
-spec controls(htmz(), binary()) -> htmz().
controls(El, Value) ->
attr(El, <<"controls"/utf8>>, Value).
-spec coords(htmz(), binary()) -> htmz().
coords(El, Value) ->
attr(El, <<"coords"/utf8>>, Value).
-spec crossorigin(htmz(), binary()) -> htmz().
crossorigin(El, Value) ->
attr(El, <<"crossorigin"/utf8>>, Value).
-spec data(htmz(), binary(), binary()) -> htmz().
data(El, Key, Value) ->
attr(El, <<"data-"/utf8, Key/binary>>, Value).
-spec datetime(htmz(), binary()) -> htmz().
datetime(El, Value) ->
attr(El, <<"datetime"/utf8>>, Value).
-spec defer(htmz()) -> htmz().
defer(El) ->
attr(El, <<"defer"/utf8>>, <<""/utf8>>).
-spec dir(htmz(), binary()) -> htmz().
dir(El, Value) ->
attr(El, <<"dir"/utf8>>, Value).
-spec dirname(htmz(), binary()) -> htmz().
dirname(El, Value) ->
attr(El, <<"dirname"/utf8>>, Value).
-spec disabled(htmz()) -> htmz().
disabled(El) ->
attr(El, <<"disabled"/utf8>>, <<""/utf8>>).
-spec download(htmz(), binary()) -> htmz().
download(El, Value) ->
attr(El, <<"download"/utf8>>, Value).
-spec draggable(htmz(), binary()) -> htmz().
draggable(El, Value) ->
attr(El, <<"draggable"/utf8>>, Value).
-spec dropzone(htmz(), binary()) -> htmz().
dropzone(El, Value) ->
attr(El, <<"dropzone"/utf8>>, Value).
-spec enctype(htmz(), binary()) -> htmz().
enctype(El, Value) ->
attr(El, <<"enctype"/utf8>>, Value).
-spec enterkeyhint(htmz(), binary()) -> htmz().
enterkeyhint(El, Value) ->
attr(El, <<"enterkeyhint"/utf8>>, Value).
-spec for(htmz(), binary()) -> htmz().
for(El, Value) ->
attr(El, <<"for"/utf8>>, Value).
-spec formaction(htmz(), binary()) -> htmz().
formaction(El, Value) ->
attr(El, <<"formaction"/utf8>>, Value).
-spec formenctype(htmz(), binary()) -> htmz().
formenctype(El, Value) ->
attr(El, <<"formenctype"/utf8>>, Value).
-spec formmethod(htmz(), binary()) -> htmz().
formmethod(El, Value) ->
attr(El, <<"formmethod"/utf8>>, Value).
-spec formnovalidate(htmz(), binary()) -> htmz().
formnovalidate(El, Value) ->
attr(El, <<"formnovalidate"/utf8>>, Value).
-spec formtarget(htmz(), binary()) -> htmz().
formtarget(El, Value) ->
attr(El, <<"formtarget"/utf8>>, Value).
-spec frameborder(htmz(), binary()) -> htmz().
frameborder(El, Value) ->
attr(El, <<"frameborder"/utf8>>, Value).
-spec headers(htmz(), binary()) -> htmz().
headers(El, Value) ->
attr(El, <<"headers"/utf8>>, Value).
-spec height(htmz(), binary()) -> htmz().
height(El, Value) ->
attr(El, <<"height"/utf8>>, Value).
-spec hidden(htmz(), binary()) -> htmz().
hidden(El, Value) ->
attr(El, <<"hidden"/utf8>>, Value).
-spec high(htmz(), binary()) -> htmz().
high(El, Value) ->
attr(El, <<"high"/utf8>>, Value).
-spec href(htmz(), binary()) -> htmz().
href(El, Value) ->
attr(El, <<"href"/utf8>>, Value).
-spec hreflang(htmz(), binary()) -> htmz().
hreflang(El, Value) ->
attr(El, <<"hreflang"/utf8>>, Value).
-spec http_equiv(htmz(), binary()) -> htmz().
http_equiv(El, Value) ->
attr(El, <<"httpEquiv"/utf8>>, Value).
-spec id(htmz(), binary()) -> htmz().
id(El, Value) ->
attr(El, <<"id"/utf8>>, Value).
-spec inputmode(htmz(), binary()) -> htmz().
inputmode(El, Value) ->
attr(El, <<"inputmode"/utf8>>, Value).
-spec integrity(htmz(), binary()) -> htmz().
integrity(El, Value) ->
attr(El, <<"integrity"/utf8>>, Value).
-spec is(htmz(), binary()) -> htmz().
is(El, Value) ->
attr(El, <<"is"/utf8>>, Value).
-spec ismap(htmz(), binary()) -> htmz().
ismap(El, Value) ->
attr(El, <<"ismap"/utf8>>, Value).
-spec kind(htmz(), binary()) -> htmz().
kind(El, Value) ->
attr(El, <<"kind"/utf8>>, Value).
-spec label(htmz(), binary()) -> htmz().
label(El, Value) ->
attr(El, <<"label"/utf8>>, Value).
-spec lang(htmz(), binary()) -> htmz().
lang(El, Value) ->
attr(El, <<"lang"/utf8>>, Value).
-spec language(htmz(), binary()) -> htmz().
language(El, Value) ->
attr(El, <<"language"/utf8>>, Value).
-spec list(htmz(), binary()) -> htmz().
list(El, Value) ->
attr(El, <<"list"/utf8>>, Value).
-spec loop_attr(htmz(), binary()) -> htmz().
loop_attr(El, Value) ->
attr(El, <<"loop"/utf8>>, Value).
-spec low(htmz(), binary()) -> htmz().
low(El, Value) ->
attr(El, <<"low"/utf8>>, Value).
-spec max(htmz(), binary()) -> htmz().
max(El, Value) ->
attr(El, <<"max"/utf8>>, Value).
-spec maxlength(htmz(), binary()) -> htmz().
maxlength(El, Value) ->
attr(El, <<"maxlength"/utf8>>, Value).
-spec method(htmz(), binary()) -> htmz().
method(El, Value) ->
attr(El, <<"method"/utf8>>, Value).
-spec min(htmz(), binary()) -> htmz().
min(El, Value) ->
attr(El, <<"min"/utf8>>, Value).
-spec minlength(htmz(), binary()) -> htmz().
minlength(El, Value) ->
attr(El, <<"minlength"/utf8>>, Value).
-spec multiple(htmz(), binary()) -> htmz().
multiple(El, Value) ->
attr(El, <<"multiple"/utf8>>, Value).
-spec name(htmz(), binary()) -> htmz().
name(El, Value) ->
attr(El, <<"name"/utf8>>, Value).
-spec novalidate(htmz(), binary()) -> htmz().
novalidate(El, Value) ->
attr(El, <<"novalidate"/utf8>>, Value).
-spec on(htmz(), binary(), binary()) -> htmz().
on(El, Event, Value) ->
attr(El, <<"on"/utf8, Event/binary>>, Value).
-spec open(htmz(), binary()) -> htmz().
open(El, Value) ->
attr(El, <<"open"/utf8>>, Value).
-spec pattern(htmz(), binary()) -> htmz().
pattern(El, Value) ->
attr(El, <<"pattern"/utf8>>, Value).
-spec placeholder(htmz(), binary()) -> htmz().
placeholder(El, Value) ->
attr(El, <<"placeholder"/utf8>>, Value).
-spec poster(htmz(), binary()) -> htmz().
poster(El, Value) ->
attr(El, <<"poster"/utf8>>, Value).
-spec preload(htmz(), binary()) -> htmz().
preload(El, Value) ->
attr(El, <<"preload"/utf8>>, Value).
-spec readonly(htmz(), binary()) -> htmz().
readonly(El, Value) ->
attr(El, <<"readonly"/utf8>>, Value).
-spec rel(htmz(), binary()) -> htmz().
rel(El, Value) ->
attr(El, <<"rel"/utf8>>, Value).
-spec required(htmz()) -> htmz().
required(El) ->
attr(El, <<"required"/utf8>>, <<""/utf8>>).
-spec reversed(htmz(), binary()) -> htmz().
reversed(El, Value) ->
attr(El, <<"reversed"/utf8>>, Value).
-spec rows(htmz(), binary()) -> htmz().
rows(El, Value) ->
attr(El, <<"rows"/utf8>>, Value).
-spec rowspan(htmz(), binary()) -> htmz().
rowspan(El, Value) ->
attr(El, <<"rowspan"/utf8>>, Value).
-spec sandbox(htmz(), binary()) -> htmz().
sandbox(El, Value) ->
attr(El, <<"sandbox"/utf8>>, Value).
-spec scope(htmz(), binary()) -> htmz().
scope(El, Value) ->
attr(El, <<"scope"/utf8>>, Value).
-spec selected(htmz()) -> htmz().
selected(El) ->
attr(El, <<"selected"/utf8>>, <<""/utf8>>).
-spec shape(htmz(), binary()) -> htmz().
shape(El, Value) ->
attr(El, <<"shape"/utf8>>, Value).
-spec size(htmz(), binary()) -> htmz().
size(El, Value) ->
attr(El, <<"size"/utf8>>, Value).
-spec sizes(htmz(), binary()) -> htmz().
sizes(El, Value) ->
attr(El, <<"sizes"/utf8>>, Value).
-spec slot(htmz(), binary()) -> htmz().
slot(El, Value) ->
attr(El, <<"slot"/utf8>>, Value).
-spec spellcheck(htmz(), binary()) -> htmz().
spellcheck(El, Value) ->
attr(El, <<"spellcheck"/utf8>>, Value).
-spec src(htmz(), binary()) -> htmz().
src(El, Value) ->
attr(El, <<"src"/utf8>>, Value).
-spec srcdoc(htmz(), binary()) -> htmz().
srcdoc(El, Value) ->
attr(El, <<"srcdoc"/utf8>>, Value).
-spec srclang(htmz(), binary()) -> htmz().
srclang(El, Value) ->
attr(El, <<"srclang"/utf8>>, Value).
-spec start(htmz(), binary()) -> htmz().
start(El, Value) ->
attr(El, <<"start"/utf8>>, Value).
-spec step(htmz(), binary()) -> htmz().
step(El, Value) ->
attr(El, <<"step"/utf8>>, Value).
-spec style(htmz(), binary()) -> htmz().
style(El, Value) ->
attr(El, <<"style"/utf8>>, Value).
-spec tabindex(htmz(), binary()) -> htmz().
tabindex(El, Value) ->
attr(El, <<"tabindex"/utf8>>, Value).
-spec target(htmz(), binary()) -> htmz().
target(El, Value) ->
attr(El, <<"target"/utf8>>, Value).
-spec title(htmz(), binary()) -> htmz().
title(El, Value) ->
attr(El, <<"title"/utf8>>, Value).
-spec translate(htmz(), binary()) -> htmz().
translate(El, Value) ->
attr(El, <<"translate"/utf8>>, Value).
-spec type_(htmz(), binary()) -> htmz().
type_(El, Value) ->
attr(El, <<"type"/utf8>>, Value).
-spec usemap(htmz(), binary()) -> htmz().
usemap(El, Value) ->
attr(El, <<"usemap"/utf8>>, Value).
-spec value(htmz(), binary()) -> htmz().
value(El, Value) ->
attr(El, <<"value"/utf8>>, Value).
-spec width(htmz(), binary()) -> htmz().
width(El, Value) ->
attr(El, <<"width"/utf8>>, Value).
-spec wrap(htmz(), binary()) -> htmz().
wrap(El, Value) ->
attr(El, <<"wrap"/utf8>>, Value).
-spec hx_boost(htmz(), binary()) -> htmz().
hx_boost(El, Value) ->
attr(El, <<"hx-boost"/utf8>>, Value).
-spec hx_confirm(htmz(), binary()) -> htmz().
hx_confirm(El, Value) ->
attr(El, <<"hx-confirm"/utf8>>, Value).
-spec hx_delete(htmz(), binary()) -> htmz().
hx_delete(El, Value) ->
attr(El, <<"hx-delete"/utf8>>, Value).
-spec hx_disabled_elt(htmz(), binary()) -> htmz().
hx_disabled_elt(El, Value) ->
attr(El, <<"hx-disabled-elt"/utf8>>, Value).
-spec hx_sync(htmz(), binary()) -> htmz().
hx_sync(El, Value) ->
attr(El, <<"hx-sync"/utf8>>, Value).
-spec hx_disinherit(htmz(), binary()) -> htmz().
hx_disinherit(El, Value) ->
attr(El, <<"hx-disinherit"/utf8>>, Value).
-spec hx_encoding(htmz(), binary()) -> htmz().
hx_encoding(El, Value) ->
attr(El, <<"hx-encoding"/utf8>>, Value).
-spec hx_ext(htmz(), binary()) -> htmz().
hx_ext(El, Value) ->
attr(El, <<"hx-ext"/utf8>>, Value).
-spec hx_get(htmz(), binary()) -> htmz().
hx_get(El, Value) ->
attr(El, <<"hx-get"/utf8>>, Value).
-spec hx_headers(htmz(), binary()) -> htmz().
hx_headers(El, Value) ->
attr(El, <<"hx-headers"/utf8>>, Value).
-spec hx_history(htmz(), binary()) -> htmz().
hx_history(El, Value) ->
attr(El, <<"hx-history"/utf8>>, Value).
-spec hx_history_elt(htmz(), binary()) -> htmz().
hx_history_elt(El, Value) ->
attr(El, <<"hx-history-elt"/utf8>>, Value).
-spec hx_include(htmz(), binary()) -> htmz().
hx_include(El, Value) ->
attr(El, <<"hx-include"/utf8>>, Value).
-spec hx_indicator(htmz(), binary()) -> htmz().
hx_indicator(El, Value) ->
attr(El, <<"hx-indicator"/utf8>>, Value).
-spec hx_on(htmz(), binary(), binary()) -> htmz().
hx_on(El, Event, Value) ->
attr(El, <<"hx-on:"/utf8, Event/binary>>, Value).
-spec hx_params(htmz(), binary()) -> htmz().
hx_params(El, Value) ->
attr(El, <<"hx-params"/utf8>>, Value).
-spec hx_post(htmz(), binary()) -> htmz().
hx_post(El, Value) ->
attr(El, <<"hx-post"/utf8>>, Value).
-spec hx_put(htmz(), binary()) -> htmz().
hx_put(El, Value) ->
attr(El, <<"hx-put"/utf8>>, Value).
-spec hx_patch(htmz(), binary()) -> htmz().
hx_patch(El, Value) ->
attr(El, <<"hx-patch"/utf8>>, Value).
-spec hx_push_url(htmz(), binary()) -> htmz().
hx_push_url(El, Value) ->
attr(El, <<"hx-push-url"/utf8>>, Value).
-spec hx_select(htmz(), binary()) -> htmz().
hx_select(El, Value) ->
attr(El, <<"hx-select"/utf8>>, Value).
-spec hx_select_oob(htmz(), binary()) -> htmz().
hx_select_oob(El, Value) ->
attr(El, <<"hx-select-oob"/utf8>>, Value).
-spec hx_swap(htmz(), binary()) -> htmz().
hx_swap(El, Value) ->
attr(El, <<"hx-swap"/utf8>>, Value).
-spec hx_swap_oob(htmz(), binary()) -> htmz().
hx_swap_oob(El, Value) ->
attr(El, <<"hx-swap-oob"/utf8>>, Value).
-spec hx_target(htmz(), binary()) -> htmz().
hx_target(El, Value) ->
attr(El, <<"hx-target"/utf8>>, Value).
-spec hx_trigger(htmz(), binary()) -> htmz().
hx_trigger(El, Value) ->
attr(El, <<"hx-trigger"/utf8>>, Value).
-spec hx_vals(htmz(), binary()) -> htmz().
hx_vals(El, Value) ->
attr(El, <<"hx-vals"/utf8>>, Value).
-spec x_data(htmz(), binary()) -> htmz().
x_data(El, Value) ->
attr(El, <<"x-data"/utf8>>, Value).
-spec x_init(htmz(), binary()) -> htmz().
x_init(El, Value) ->
attr(El, <<"x-init"/utf8>>, Value).
-spec x_show(htmz(), binary()) -> htmz().
x_show(El, Value) ->
attr(El, <<"x-show"/utf8>>, Value).
-spec x_bind(htmz(), binary(), binary()) -> htmz().
x_bind(El, Field, Value) ->
attr(El, <<"x-bind:"/utf8, Field/binary>>, Value).
-spec x_on(htmz(), binary(), binary()) -> htmz().
x_on(El, Event, Value) ->
attr(El, <<"x-on:"/utf8, Event/binary>>, Value).
-spec x_text(htmz(), binary()) -> htmz().
x_text(El, Value) ->
attr(El, <<"x-text"/utf8>>, Value).
-spec x_html(htmz(), binary()) -> htmz().
x_html(El, Value) ->
attr(El, <<"x-html"/utf8>>, Value).
-spec x_model(htmz(), binary()) -> htmz().
x_model(El, Value) ->
attr(El, <<"x-model"/utf8>>, Value).
-spec x_modelable(htmz(), binary()) -> htmz().
x_modelable(El, Value) ->
attr(El, <<"x-modelable"/utf8>>, Value).
-spec x_for(htmz(), binary()) -> htmz().
x_for(El, Value) ->
attr(El, <<"x-for"/utf8>>, Value).
-spec x_transition(htmz()) -> htmz().
x_transition(El) ->
attr(El, <<"x-transition"/utf8>>, <<""/utf8>>).
-spec x_transition_a(htmz(), binary(), binary()) -> htmz().
x_transition_a(El, Modifier, Value) ->
attr(El, <<"x-transition:"/utf8, Modifier/binary>>, Value).
-spec x_effect(htmz(), binary()) -> htmz().
x_effect(El, Value) ->
attr(El, <<"x-effect"/utf8>>, Value).
-spec x_ignore(htmz(), binary()) -> htmz().
x_ignore(El, Value) ->
attr(El, <<"x-ignore"/utf8>>, Value).
-spec x_ref(htmz(), binary()) -> htmz().
x_ref(El, Value) ->
attr(El, <<"x-ref"/utf8>>, Value).
-spec x_cloak(htmz(), binary()) -> htmz().
x_cloak(El, Value) ->
attr(El, <<"x-cloak"/utf8>>, Value).
-spec x_teleport(htmz(), binary()) -> htmz().
x_teleport(El, Value) ->
attr(El, <<"x-teleport"/utf8>>, Value).
-spec x_if(htmz(), binary()) -> htmz().
x_if(El, Value) ->
attr(El, <<"x-if"/utf8>>, Value).
-spec x_id(htmz(), binary()) -> htmz().
x_id(El, Value) ->
attr(El, <<"x-id"/utf8>>, Value).
-spec to_string(htmz()) -> binary().
to_string(El) ->
case El of
{text, Text} ->
escape(Text);
_ ->
{Tag, Attrs, Children} = to_tuple(El),
case Tag of
<<""/utf8>> ->
<<""/utf8>>;
<<"input"/utf8>> ->
<<<<<<"<"/utf8, Tag/binary>>/binary,
(attrs_to_string(Attrs))/binary>>/binary,
"/>\n"/utf8>>;
<<"br"/utf8>> ->
<<<<<<"<"/utf8, Tag/binary>>/binary,
(attrs_to_string(Attrs))/binary>>/binary,
"/>\n"/utf8>>;
<<"hr"/utf8>> ->
<<<<<<"<"/utf8, Tag/binary>>/binary,
(attrs_to_string(Attrs))/binary>>/binary,
"/>\n"/utf8>>;
<<"img"/utf8>> ->
<<<<<<"<"/utf8, Tag/binary>>/binary,
(attrs_to_string(Attrs))/binary>>/binary,
"/>\n"/utf8>>;
<<"link"/utf8>> ->
<<<<<<"<"/utf8, Tag/binary>>/binary,
(attrs_to_string(Attrs))/binary>>/binary,
"/>\n"/utf8>>;
<<"meta"/utf8>> ->
<<<<<<"<"/utf8, Tag/binary>>/binary,
(attrs_to_string(Attrs))/binary>>/binary,
"/>\n"/utf8>>;
_ ->
<<<<<<<<<<<<<<"<"/utf8, Tag/binary>>/binary,
(attrs_to_string(Attrs))/binary>>/binary,
">\n"/utf8>>/binary,
(children_to_string(Children))/binary>>/binary,
"</"/utf8>>/binary,
Tag/binary>>/binary,
">"/utf8>>
end
end.
-spec children_to_string(list(htmz())) -> binary().
children_to_string(Children) ->
_pipe = Children,
_pipe@1 = gleam@list:map(_pipe, fun to_string/1),
gleam@string:join(_pipe@1, <<""/utf8>>).