Packages

A DSL for generating HTML in Gleam

Current section

Files

Jump to
html_dsl src html_dsl@types@html.erl
Raw

src/html_dsl@types@html.erl

-module(html_dsl@types@html).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-export([is_html/1, html_to_string/1, new_element/1, attribute/2, render_attribute/1, 'div'/4, img/5, a/5, h1/4, h2/4, h3/4, h4/4, h5/4, h6/4, p/4, span/4, li/4, ul/4, ol/4, br/0, hr/0, script/1, link/3, style/1, meta/2, charset/1, title/1, head/1, body/4, html/2, component/1, input/5, label/4, form/4, header/4, footer/4, nav/4, section/4, article/4, aside/4, main/4, button/4, select/4, option/2]).
-export_type([attribute/0, option/0, list_item/0, input/0, html/0, head/0]).
-type attribute() :: {attribute, binary(), binary()}.
-opaque option() :: {option, binary()}.
-opaque list_item() :: {list_item, binary()}.
-opaque input() :: {input, binary()} | {label, binary()} | {element, binary()}.
-opaque html() :: {html, binary()} | {component, binary()}.
-opaque head() :: {meta, binary()} |
{title, binary()} |
{link, binary()} |
{style, binary()} |
{script, binary()}.
-spec is_html(html()) -> boolean().
is_html(Html) ->
case Html of
{html, _} ->
true;
{component, _} ->
false
end.
-spec html_to_string(html()) -> binary().
html_to_string(Html) ->
case Html of
{html, Content} ->
Content;
{component, Content@1} ->
Content@1
end.
-spec new_element(binary()) -> input().
new_element(Content) ->
{element, Content}.
-spec attribute(binary(), binary()) -> attribute().
attribute(Key, Value) ->
{attribute, Key, Value}.
-spec render_attribute(attribute()) -> binary().
render_attribute(Attribute) ->
{attribute, Key, Value} = Attribute,
<<<<<<Key/binary, "=\""/utf8>>/binary, Value/binary>>/binary, "\""/utf8>>.
-spec 'div'(
html_dsl@types@id:id(),
html_dsl@types@class:class(),
list(attribute()),
binary()
) -> binary().
'div'(Id, Class, Attributes, Child) ->
Att_str = gleam@list:fold(case Id of
{id, Id@1} ->
gleam@list:append(
Attributes,
[{attribute, <<"id"/utf8>>, Id@1}]
);
nil ->
Attributes
end, <<""/utf8>>, fun(Str, A) ->
<<<<Str/binary, " "/utf8>>/binary,
(render_attribute(
{attribute,
html_dsl@utils@check:illegal_string_check(
erlang:element(2, A)
),
html_dsl@utils@check:illegal_string_check(
erlang:element(3, A)
)}
))/binary>>
end),
case Class of
{class, Class@1} ->
Class@2 = html_dsl@utils@check:illegal_string_check(Class@1),
<<<<<<<<<<<<"<div class=\""/utf8, Class@2/binary>>/binary,
"\""/utf8>>/binary,
Att_str/binary>>/binary,
">"/utf8>>/binary,
Child/binary>>/binary,
"</div>"/utf8>>;
nil ->
<<<<<<<<"<div"/utf8, Att_str/binary>>/binary, ">"/utf8>>/binary,
Child/binary>>/binary,
"</div>"/utf8>>
end.
-spec img(
html_dsl@types@id:id(),
html_dsl@types@class:class(),
binary(),
binary(),
list(attribute())
) -> binary().
img(Id, Class, Src, Alt, Attributes) ->
Att_str = gleam@list:fold(case Id of
{id, Id@1} ->
gleam@list:append(
Attributes,
[{attribute, <<"id"/utf8>>, Id@1}]
);
nil ->
Attributes
end, <<""/utf8>>, fun(Str, A) ->
<<<<Str/binary, " "/utf8>>/binary,
(render_attribute(
{attribute,
html_dsl@utils@check:illegal_string_check(
erlang:element(2, A)
),
html_dsl@utils@check:illegal_string_check(
erlang:element(3, A)
)}
))/binary>>
end),
case Class of
{class, Class@1} ->
Class@2 = html_dsl@utils@check:illegal_string_check(Class@1),
<<<<<<<<<<<<<<<<"<img src=\""/utf8, Src/binary>>/binary,
"\" alt=\""/utf8>>/binary,
Alt/binary>>/binary,
"\" class=\""/utf8>>/binary,
Class@2/binary>>/binary,
"\""/utf8>>/binary,
Att_str/binary>>/binary,
"/>"/utf8>>;
nil ->
<<<<<<<<<<<<"<img src=\""/utf8, Src/binary>>/binary,
"\" alt=\""/utf8>>/binary,
Alt/binary>>/binary,
"\""/utf8>>/binary,
Att_str/binary>>/binary,
"/>"/utf8>>
end.
-spec a(
html_dsl@types@id:id(),
html_dsl@types@class:class(),
binary(),
list(attribute()),
binary()
) -> binary().
a(Id, Class, Href, Attributes, Child) ->
Att_str = gleam@list:fold(case Id of
{id, Id@1} ->
gleam@list:append(
Attributes,
[{attribute, <<"id"/utf8>>, Id@1}]
);
nil ->
Attributes
end, <<""/utf8>>, fun(Str, A) ->
<<<<Str/binary, " "/utf8>>/binary,
(render_attribute(
{attribute,
html_dsl@utils@check:illegal_string_check(
erlang:element(2, A)
),
html_dsl@utils@check:illegal_string_check(
erlang:element(3, A)
)}
))/binary>>
end),
case Class of
{class, Class@1} ->
Class@2 = html_dsl@utils@check:illegal_string_check(Class@1),
<<<<<<<<<<<<<<<<"<a href=\""/utf8, Href/binary>>/binary,
"\" class=\""/utf8>>/binary,
Class@2/binary>>/binary,
"\""/utf8>>/binary,
Att_str/binary>>/binary,
">"/utf8>>/binary,
Child/binary>>/binary,
"</a>"/utf8>>;
nil ->
<<<<<<<<<<<<"<a href=\""/utf8, Href/binary>>/binary, "\""/utf8>>/binary,
Att_str/binary>>/binary,
">"/utf8>>/binary,
Child/binary>>/binary,
"</a>"/utf8>>
end.
-spec h1(
html_dsl@types@id:id(),
html_dsl@types@class:class(),
list(attribute()),
binary()
) -> binary().
h1(Id, Class, Attributes, Child) ->
Att_str = gleam@list:fold(case Id of
{id, Id@1} ->
gleam@list:append(
Attributes,
[{attribute, <<"id"/utf8>>, Id@1}]
);
nil ->
Attributes
end, <<""/utf8>>, fun(Str, A) ->
<<<<Str/binary, " "/utf8>>/binary,
(render_attribute(
{attribute,
html_dsl@utils@check:illegal_string_check(
erlang:element(2, A)
),
html_dsl@utils@check:illegal_string_check(
erlang:element(3, A)
)}
))/binary>>
end),
case Class of
{class, Class@1} ->
Class@2 = html_dsl@utils@check:illegal_string_check(Class@1),
<<<<<<<<<<<<"<h1 class=\""/utf8, Class@2/binary>>/binary,
"\""/utf8>>/binary,
Att_str/binary>>/binary,
">"/utf8>>/binary,
Child/binary>>/binary,
"</h1>"/utf8>>;
nil ->
<<<<<<<<"<h1"/utf8, Att_str/binary>>/binary, ">"/utf8>>/binary,
Child/binary>>/binary,
"</h1>"/utf8>>
end.
-spec h2(
html_dsl@types@id:id(),
html_dsl@types@class:class(),
list(attribute()),
binary()
) -> binary().
h2(Id, Class, Attributes, Child) ->
Att_str = gleam@list:fold(case Id of
{id, Id@1} ->
gleam@list:append(
Attributes,
[{attribute, <<"id"/utf8>>, Id@1}]
);
nil ->
Attributes
end, <<""/utf8>>, fun(Str, A) ->
<<<<Str/binary, " "/utf8>>/binary,
(render_attribute(
{attribute,
html_dsl@utils@check:illegal_string_check(
erlang:element(2, A)
),
html_dsl@utils@check:illegal_string_check(
erlang:element(3, A)
)}
))/binary>>
end),
case Class of
{class, Class@1} ->
Class@2 = html_dsl@utils@check:illegal_string_check(Class@1),
<<<<<<<<<<<<"<h2 class=\""/utf8, Class@2/binary>>/binary,
"\""/utf8>>/binary,
Att_str/binary>>/binary,
">"/utf8>>/binary,
Child/binary>>/binary,
"</h2>"/utf8>>;
nil ->
<<<<<<<<"<h2"/utf8, Att_str/binary>>/binary, ">"/utf8>>/binary,
Child/binary>>/binary,
"</h2>"/utf8>>
end.
-spec h3(
html_dsl@types@id:id(),
html_dsl@types@class:class(),
list(attribute()),
binary()
) -> binary().
h3(Id, Class, Attributes, Child) ->
Att_str = gleam@list:fold(case Id of
{id, Id@1} ->
gleam@list:append(
Attributes,
[{attribute, <<"id"/utf8>>, Id@1}]
);
nil ->
Attributes
end, <<""/utf8>>, fun(Str, A) ->
<<<<Str/binary, " "/utf8>>/binary,
(render_attribute(
{attribute,
html_dsl@utils@check:illegal_string_check(
erlang:element(2, A)
),
html_dsl@utils@check:illegal_string_check(
erlang:element(3, A)
)}
))/binary>>
end),
case Class of
{class, Class@1} ->
Class@2 = html_dsl@utils@check:illegal_string_check(Class@1),
<<<<<<<<<<<<"<h3 class=\""/utf8, Class@2/binary>>/binary,
"\""/utf8>>/binary,
Att_str/binary>>/binary,
">"/utf8>>/binary,
Child/binary>>/binary,
"</h3>"/utf8>>;
nil ->
<<<<<<<<"<h3"/utf8, Att_str/binary>>/binary, ">"/utf8>>/binary,
Child/binary>>/binary,
"</h3>"/utf8>>
end.
-spec h4(
html_dsl@types@id:id(),
html_dsl@types@class:class(),
list(attribute()),
binary()
) -> binary().
h4(Id, Class, Attributes, Child) ->
Att_str = gleam@list:fold(case Id of
{id, Id@1} ->
gleam@list:append(
Attributes,
[{attribute, <<"id"/utf8>>, Id@1}]
);
nil ->
Attributes
end, <<""/utf8>>, fun(Str, A) ->
<<<<Str/binary, " "/utf8>>/binary,
(render_attribute(
{attribute,
html_dsl@utils@check:illegal_string_check(
erlang:element(2, A)
),
html_dsl@utils@check:illegal_string_check(
erlang:element(3, A)
)}
))/binary>>
end),
case Class of
{class, Class@1} ->
Class@2 = html_dsl@utils@check:illegal_string_check(Class@1),
<<<<<<<<<<<<"<h4 class=\""/utf8, Class@2/binary>>/binary,
"\""/utf8>>/binary,
Att_str/binary>>/binary,
">"/utf8>>/binary,
Child/binary>>/binary,
"</h4>"/utf8>>;
nil ->
<<<<<<<<"<h4"/utf8, Att_str/binary>>/binary, ">"/utf8>>/binary,
Child/binary>>/binary,
"</h4>"/utf8>>
end.
-spec h5(
html_dsl@types@id:id(),
html_dsl@types@class:class(),
list(attribute()),
binary()
) -> binary().
h5(Id, Class, Attributes, Child) ->
Att_str = gleam@list:fold(case Id of
{id, Id@1} ->
gleam@list:append(
Attributes,
[{attribute, <<"id"/utf8>>, Id@1}]
);
nil ->
Attributes
end, <<""/utf8>>, fun(Str, A) ->
<<<<Str/binary, " "/utf8>>/binary,
(render_attribute(
{attribute,
html_dsl@utils@check:illegal_string_check(
erlang:element(2, A)
),
html_dsl@utils@check:illegal_string_check(
erlang:element(3, A)
)}
))/binary>>
end),
case Class of
{class, Class@1} ->
Class@2 = html_dsl@utils@check:illegal_string_check(Class@1),
<<<<<<<<<<<<"<h5 class=\""/utf8, Class@2/binary>>/binary,
"\""/utf8>>/binary,
Att_str/binary>>/binary,
">"/utf8>>/binary,
Child/binary>>/binary,
"</h5>"/utf8>>;
nil ->
<<<<<<<<"<h5"/utf8, Att_str/binary>>/binary, ">"/utf8>>/binary,
Child/binary>>/binary,
"</h5>"/utf8>>
end.
-spec h6(
html_dsl@types@id:id(),
html_dsl@types@class:class(),
list(attribute()),
binary()
) -> binary().
h6(Id, Class, Attributes, Child) ->
Att_str = gleam@list:fold(case Id of
{id, Id@1} ->
gleam@list:append(
Attributes,
[{attribute, <<"id"/utf8>>, Id@1}]
);
nil ->
Attributes
end, <<""/utf8>>, fun(Str, A) ->
<<<<Str/binary, " "/utf8>>/binary,
(render_attribute(
{attribute,
html_dsl@utils@check:illegal_string_check(
erlang:element(2, A)
),
html_dsl@utils@check:illegal_string_check(
erlang:element(3, A)
)}
))/binary>>
end),
case Class of
{class, Class@1} ->
Class@2 = html_dsl@utils@check:illegal_string_check(Class@1),
<<<<<<<<<<<<"<h6 class=\""/utf8, Class@2/binary>>/binary,
"\""/utf8>>/binary,
Att_str/binary>>/binary,
">"/utf8>>/binary,
Child/binary>>/binary,
"</h6>"/utf8>>;
nil ->
<<<<<<<<"<h6"/utf8, Att_str/binary>>/binary, ">"/utf8>>/binary,
Child/binary>>/binary,
"</h6>"/utf8>>
end.
-spec p(
html_dsl@types@id:id(),
html_dsl@types@class:class(),
list(attribute()),
binary()
) -> binary().
p(Id, Class, Attributes, Child) ->
Att_str = gleam@list:fold(case Id of
{id, Id@1} ->
gleam@list:append(
Attributes,
[{attribute, <<"id"/utf8>>, Id@1}]
);
nil ->
Attributes
end, <<""/utf8>>, fun(Str, A) ->
<<<<Str/binary, " "/utf8>>/binary,
(render_attribute(
{attribute,
html_dsl@utils@check:illegal_string_check(
erlang:element(2, A)
),
html_dsl@utils@check:illegal_string_check(
erlang:element(3, A)
)}
))/binary>>
end),
case Class of
{class, Class@1} ->
Class@2 = html_dsl@utils@check:illegal_string_check(Class@1),
<<<<<<<<<<<<"<p class=\""/utf8, Class@2/binary>>/binary, "\""/utf8>>/binary,
Att_str/binary>>/binary,
">"/utf8>>/binary,
Child/binary>>/binary,
"</p>"/utf8>>;
nil ->
<<<<<<<<"<p"/utf8, Att_str/binary>>/binary, ">"/utf8>>/binary,
Child/binary>>/binary,
"</p>"/utf8>>
end.
-spec span(
html_dsl@types@id:id(),
html_dsl@types@class:class(),
list(attribute()),
binary()
) -> binary().
span(Id, Class, Attributes, Child) ->
Att_str = gleam@list:fold(case Id of
{id, Id@1} ->
gleam@list:append(
Attributes,
[{attribute, <<"id"/utf8>>, Id@1}]
);
nil ->
Attributes
end, <<""/utf8>>, fun(Str, A) ->
<<<<Str/binary, " "/utf8>>/binary,
(render_attribute(
{attribute,
html_dsl@utils@check:illegal_string_check(
erlang:element(2, A)
),
html_dsl@utils@check:illegal_string_check(
erlang:element(3, A)
)}
))/binary>>
end),
case Class of
{class, Class@1} ->
Class@2 = html_dsl@utils@check:illegal_string_check(Class@1),
<<<<<<<<<<<<"<span class=\""/utf8, Class@2/binary>>/binary,
"\""/utf8>>/binary,
Att_str/binary>>/binary,
">"/utf8>>/binary,
Child/binary>>/binary,
"</span>"/utf8>>;
nil ->
<<<<<<<<"<span"/utf8, Att_str/binary>>/binary, ">"/utf8>>/binary,
Child/binary>>/binary,
"</span>"/utf8>>
end.
-spec li(
html_dsl@types@id:id(),
html_dsl@types@class:class(),
list(attribute()),
binary()
) -> list_item().
li(Id, Class, Attributes, Child) ->
Att_str = gleam@list:fold(case Id of
{id, Id@1} ->
gleam@list:append(
Attributes,
[{attribute, <<"id"/utf8>>, Id@1}]
);
nil ->
Attributes
end, <<""/utf8>>, fun(Str, A) ->
<<<<Str/binary, " "/utf8>>/binary,
(render_attribute(
{attribute,
html_dsl@utils@check:illegal_string_check(
erlang:element(2, A)
),
html_dsl@utils@check:illegal_string_check(
erlang:element(3, A)
)}
))/binary>>
end),
case Class of
{class, Class@1} ->
Class@2 = html_dsl@utils@check:illegal_string_check(Class@1),
{list_item,
<<<<<<<<<<<<"<li class=\""/utf8, Class@2/binary>>/binary,
"\""/utf8>>/binary,
Att_str/binary>>/binary,
">"/utf8>>/binary,
Child/binary>>/binary,
"</li>"/utf8>>};
nil ->
{list_item,
<<<<<<<<"<li"/utf8, Att_str/binary>>/binary, ">"/utf8>>/binary,
Child/binary>>/binary,
"</li>"/utf8>>}
end.
-spec ul(
html_dsl@types@id:id(),
html_dsl@types@class:class(),
list(attribute()),
list(list_item())
) -> binary().
ul(Id, Class, Attributes, Children) ->
Att_str = gleam@list:fold(case Id of
{id, Id@1} ->
gleam@list:append(
Attributes,
[{attribute, <<"id"/utf8>>, Id@1}]
);
nil ->
Attributes
end, <<""/utf8>>, fun(Str, A) ->
<<<<Str/binary, " "/utf8>>/binary,
(render_attribute(
{attribute,
html_dsl@utils@check:illegal_string_check(
erlang:element(2, A)
),
html_dsl@utils@check:illegal_string_check(
erlang:element(3, A)
)}
))/binary>>
end),
Children_str = gleam@list:fold(
Children,
<<""/utf8>>,
fun(Str@1, List_item) -> <<Str@1/binary, (case List_item of
{list_item, Child} ->
Child
end)/binary>> end
),
case Class of
{class, Class@1} ->
Class@2 = html_dsl@utils@check:illegal_string_check(Class@1),
<<<<<<<<<<<<"<ul class=\""/utf8, Class@2/binary>>/binary,
"\""/utf8>>/binary,
Att_str/binary>>/binary,
">"/utf8>>/binary,
Children_str/binary>>/binary,
"</ul>"/utf8>>;
nil ->
<<<<<<<<"<ul"/utf8, Att_str/binary>>/binary, ">"/utf8>>/binary,
Children_str/binary>>/binary,
"</ul>"/utf8>>
end.
-spec ol(
html_dsl@types@id:id(),
html_dsl@types@class:class(),
list(attribute()),
list(list_item())
) -> binary().
ol(Id, Class, Attributes, Children) ->
Att_str = gleam@list:fold(case Id of
{id, Id@1} ->
gleam@list:append(
Attributes,
[{attribute, <<"id"/utf8>>, Id@1}]
);
nil ->
Attributes
end, <<""/utf8>>, fun(Str, A) ->
<<<<Str/binary, " "/utf8>>/binary,
(render_attribute(
{attribute,
html_dsl@utils@check:illegal_string_check(
erlang:element(2, A)
),
html_dsl@utils@check:illegal_string_check(
erlang:element(3, A)
)}
))/binary>>
end),
Children_str = gleam@list:fold(
Children,
<<""/utf8>>,
fun(Str@1, List_item) -> <<Str@1/binary, (case List_item of
{list_item, Child} ->
Child
end)/binary>> end
),
case Class of
{class, Class@1} ->
Class@2 = html_dsl@utils@check:illegal_string_check(Class@1),
<<<<<<<<<<<<"<ol class=\""/utf8, Class@2/binary>>/binary,
"\""/utf8>>/binary,
Att_str/binary>>/binary,
">"/utf8>>/binary,
Children_str/binary>>/binary,
"</ol>"/utf8>>;
nil ->
<<<<<<<<"<ol"/utf8, Att_str/binary>>/binary, ">"/utf8>>/binary,
Children_str/binary>>/binary,
"</ol>"/utf8>>
end.
-spec br() -> binary().
br() ->
<<"<br>"/utf8>>.
-spec hr() -> binary().
hr() ->
<<"<hr>"/utf8>>.
-spec script(binary()) -> head().
script(Src) ->
Src@1 = html_dsl@utils@check:illegal_string_check(Src),
{script,
<<<<"<script src=\""/utf8, Src@1/binary>>/binary, "\"></script>"/utf8>>}.
-spec link(binary(), binary(), list(attribute())) -> head().
link(Rel, Href, Attributes) ->
Att_str = gleam@list:fold(
Attributes,
<<""/utf8>>,
fun(Str, A) ->
<<<<Str/binary, " "/utf8>>/binary,
(render_attribute(
{attribute,
html_dsl@utils@check:illegal_string_check(
erlang:element(2, A)
),
html_dsl@utils@check:illegal_string_check(
erlang:element(3, A)
)}
))/binary>>
end
),
Rel@1 = html_dsl@utils@check:illegal_string_check(Rel),
Href@1 = html_dsl@utils@check:illegal_string_check(Href),
{link,
<<<<<<<<<<<<"<link rel=\""/utf8, Rel@1/binary>>/binary,
"\" href=\""/utf8>>/binary,
Href@1/binary>>/binary,
"\""/utf8>>/binary,
Att_str/binary>>/binary,
">"/utf8>>}.
-spec style(binary()) -> head().
style(Src) ->
Src@1 = html_dsl@utils@check:illegal_string_check(Src),
{style,
<<<<"<link rel=\"stylesheet\" href=\""/utf8, Src@1/binary>>/binary,
"\">"/utf8>>}.
-spec meta(binary(), binary()) -> head().
meta(Name, Content) ->
Name@1 = html_dsl@utils@check:illegal_string_check(Name),
{meta,
<<<<<<<<"<meta name=\""/utf8, Name@1/binary>>/binary,
"\" content=\""/utf8>>/binary,
Content/binary>>/binary,
"\">"/utf8>>}.
-spec charset(binary()) -> head().
charset(Set) ->
Set@1 = html_dsl@utils@check:illegal_string_check(Set),
{meta, <<<<"<meta charset=\""/utf8, Set@1/binary>>/binary, "\">"/utf8>>}.
-spec title(binary()) -> head().
title(Content) ->
Content@1 = html_dsl@utils@check:illegal_string_check(Content),
{title, <<<<"<title>"/utf8, Content@1/binary>>/binary, "</title>"/utf8>>}.
-spec head(list(head())) -> binary().
head(Children) ->
<<(gleam@list:fold(
Children,
<<"<head>"/utf8>>,
fun(Str, Head) -> <<Str/binary, (case Head of
{meta, Meta} ->
Meta;
{title, Title} ->
Title;
{link, Link} ->
Link;
{style, Style} ->
Style;
{script, Script} ->
Script
end)/binary>> end
))/binary,
"</head>"/utf8>>.
-spec body(
html_dsl@types@id:id(),
html_dsl@types@class:class(),
list(attribute()),
binary()
) -> binary().
body(Id, Class, Attributes, Children) ->
Att_str = gleam@list:fold(case Id of
{id, Id@1} ->
gleam@list:append(
Attributes,
[{attribute, <<"id"/utf8>>, Id@1}]
);
nil ->
Attributes
end, <<""/utf8>>, fun(Str, A) ->
<<<<Str/binary, " "/utf8>>/binary,
(render_attribute(
{attribute,
html_dsl@utils@check:illegal_string_check(
erlang:element(2, A)
),
html_dsl@utils@check:illegal_string_check(
erlang:element(3, A)
)}
))/binary>>
end),
case Class of
{class, Class@1} ->
Class@2 = html_dsl@utils@check:illegal_string_check(Class@1),
<<<<<<<<<<<<"<body class=\""/utf8, Class@2/binary>>/binary,
"\""/utf8>>/binary,
Att_str/binary>>/binary,
">"/utf8>>/binary,
Children/binary>>/binary,
"</body>"/utf8>>;
nil ->
<<<<<<<<"<body"/utf8, Att_str/binary>>/binary, ">"/utf8>>/binary,
Children/binary>>/binary,
"</body>"/utf8>>
end.
-spec html(binary(), binary()) -> html().
html(Lang, Children) ->
Lang@1 = html_dsl@utils@check:illegal_string_check(Lang),
{html,
<<<<<<<<"<!DOCTYPE html><html lang=\""/utf8, Lang@1/binary>>/binary,
"\">"/utf8>>/binary,
Children/binary>>/binary,
"</html>"/utf8>>}.
-spec component(binary()) -> html().
component(Content) ->
{component, Content}.
-spec input(
html_dsl@types@id:id(),
html_dsl@types@class:class(),
list(attribute()),
html_dsl@types@input:input_type(),
binary()
) -> input().
input(Id, Class, Attributes, Input_type, Placeholder) ->
Att_str = gleam@list:fold(case Id of
{id, Id@1} ->
gleam@list:append(
Attributes,
[{attribute, <<"id"/utf8>>, Id@1}]
);
nil ->
Attributes
end, <<""/utf8>>, fun(Str, A) ->
<<<<Str/binary, " "/utf8>>/binary,
(render_attribute(
{attribute,
html_dsl@utils@check:illegal_string_check(
erlang:element(2, A)
),
html_dsl@utils@check:illegal_string_check(
erlang:element(3, A)
)}
))/binary>>
end),
{input, case Class of
{class, Class@1} ->
Class@2 = html_dsl@utils@check:illegal_string_check(Class@1),
<<<<<<<<<<<<<<<<"<input "/utf8,
(html_dsl@types@input:input_type_to_attribute(
Input_type
))/binary>>/binary,
" placeholder=\""/utf8>>/binary,
Placeholder/binary>>/binary,
"\" class=\""/utf8>>/binary,
Class@2/binary>>/binary,
"\""/utf8>>/binary,
Att_str/binary>>/binary,
"/>"/utf8>>;
nil ->
<<<<<<<<<<<<"<input "/utf8,
(html_dsl@types@input:input_type_to_attribute(
Input_type
))/binary>>/binary,
" placeholder=\""/utf8>>/binary,
Placeholder/binary>>/binary,
"\""/utf8>>/binary,
Att_str/binary>>/binary,
"/>"/utf8>>
end}.
-spec label(
html_dsl@types@id:id(),
html_dsl@types@class:class(),
list(attribute()),
binary()
) -> input().
label(Id, Class, Attributes, Child) ->
Att_str = gleam@list:fold(case Id of
{id, Id@1} ->
gleam@list:append(
Attributes,
[{attribute, <<"id"/utf8>>, Id@1}]
);
nil ->
Attributes
end, <<""/utf8>>, fun(Str, A) ->
<<<<Str/binary, " "/utf8>>/binary,
(render_attribute(
{attribute,
html_dsl@utils@check:illegal_string_check(
erlang:element(2, A)
),
html_dsl@utils@check:illegal_string_check(
erlang:element(3, A)
)}
))/binary>>
end),
{label, case Class of
{class, Class@1} ->
Class@2 = html_dsl@utils@check:illegal_string_check(Class@1),
<<<<<<<<<<<<"<label class=\""/utf8, Class@2/binary>>/binary,
"\""/utf8>>/binary,
Att_str/binary>>/binary,
">"/utf8>>/binary,
Child/binary>>/binary,
"</label>"/utf8>>;
nil ->
<<<<<<<<"<label"/utf8, Att_str/binary>>/binary, ">"/utf8>>/binary,
Child/binary>>/binary,
"</label>"/utf8>>
end}.
-spec form(
html_dsl@types@id:id(),
html_dsl@types@class:class(),
list(attribute()),
list(input())
) -> binary().
form(Id, Class, Attributes, Children) ->
Att_str = gleam@list:fold(case Id of
{id, Id@1} ->
gleam@list:append(
Attributes,
[{attribute, <<"id"/utf8>>, Id@1}]
);
nil ->
Attributes
end, <<""/utf8>>, fun(Str, A) ->
<<<<Str/binary, " "/utf8>>/binary,
(render_attribute(
{attribute,
html_dsl@utils@check:illegal_string_check(
erlang:element(2, A)
),
html_dsl@utils@check:illegal_string_check(
erlang:element(3, A)
)}
))/binary>>
end),
Children_str = gleam@list:fold(
Children,
<<""/utf8>>,
fun(Str@1, Input) -> <<Str@1/binary, (case Input of
{input, Child} ->
Child;
{element, Child@1} ->
Child@1;
{label, Child@2} ->
Child@2
end)/binary>> end
),
case Class of
{class, Class@1} ->
Class@2 = html_dsl@utils@check:illegal_string_check(Class@1),
<<<<<<<<<<<<"<form class=\""/utf8, Class@2/binary>>/binary,
"\""/utf8>>/binary,
Att_str/binary>>/binary,
">"/utf8>>/binary,
Children_str/binary>>/binary,
"</form>"/utf8>>;
nil ->
<<<<<<<<"<form"/utf8, Att_str/binary>>/binary, ">"/utf8>>/binary,
Children_str/binary>>/binary,
"</form>"/utf8>>
end.
-spec header(
html_dsl@types@id:id(),
html_dsl@types@class:class(),
list(attribute()),
binary()
) -> binary().
header(Id, Class, Attributes, Children) ->
Att_str = gleam@list:fold(case Id of
{id, Id@1} ->
gleam@list:append(
Attributes,
[{attribute, <<"id"/utf8>>, Id@1}]
);
nil ->
Attributes
end, <<""/utf8>>, fun(Str, A) ->
<<<<Str/binary, " "/utf8>>/binary,
(render_attribute(
{attribute,
html_dsl@utils@check:illegal_string_check(
erlang:element(2, A)
),
html_dsl@utils@check:illegal_string_check(
erlang:element(3, A)
)}
))/binary>>
end),
case Class of
{class, Class@1} ->
Class@2 = html_dsl@utils@check:illegal_string_check(Class@1),
<<<<<<<<<<<<"<header class=\""/utf8, Class@2/binary>>/binary,
"\""/utf8>>/binary,
Att_str/binary>>/binary,
">"/utf8>>/binary,
Children/binary>>/binary,
"</header>"/utf8>>;
nil ->
<<<<<<<<"<header"/utf8, Att_str/binary>>/binary, ">"/utf8>>/binary,
Children/binary>>/binary,
"</header>"/utf8>>
end.
-spec footer(
html_dsl@types@id:id(),
html_dsl@types@class:class(),
list(attribute()),
binary()
) -> binary().
footer(Id, Class, Attributes, Children) ->
Att_str = gleam@list:fold(case Id of
{id, Id@1} ->
gleam@list:append(
Attributes,
[{attribute, <<"id"/utf8>>, Id@1}]
);
nil ->
Attributes
end, <<""/utf8>>, fun(Str, A) ->
<<<<Str/binary, " "/utf8>>/binary,
(render_attribute(
{attribute,
html_dsl@utils@check:illegal_string_check(
erlang:element(2, A)
),
html_dsl@utils@check:illegal_string_check(
erlang:element(3, A)
)}
))/binary>>
end),
case Class of
{class, Class@1} ->
Class@2 = html_dsl@utils@check:illegal_string_check(Class@1),
<<<<<<<<<<<<"<footer class=\""/utf8, Class@2/binary>>/binary,
"\""/utf8>>/binary,
Att_str/binary>>/binary,
">"/utf8>>/binary,
Children/binary>>/binary,
"</footer>"/utf8>>;
nil ->
<<<<<<<<"<footer"/utf8, Att_str/binary>>/binary, ">"/utf8>>/binary,
Children/binary>>/binary,
"</footer>"/utf8>>
end.
-spec nav(
html_dsl@types@id:id(),
html_dsl@types@class:class(),
list(attribute()),
binary()
) -> binary().
nav(Id, Class, Attributes, Children) ->
Att_str = gleam@list:fold(case Id of
{id, Id@1} ->
gleam@list:append(
Attributes,
[{attribute, <<"id"/utf8>>, Id@1}]
);
nil ->
Attributes
end, <<""/utf8>>, fun(Str, A) ->
<<<<Str/binary, " "/utf8>>/binary,
(render_attribute(
{attribute,
html_dsl@utils@check:illegal_string_check(
erlang:element(2, A)
),
html_dsl@utils@check:illegal_string_check(
erlang:element(3, A)
)}
))/binary>>
end),
case Class of
{class, Class@1} ->
Class@2 = html_dsl@utils@check:illegal_string_check(Class@1),
<<<<<<<<<<<<"<nav class=\""/utf8, Class@2/binary>>/binary,
"\""/utf8>>/binary,
Att_str/binary>>/binary,
">"/utf8>>/binary,
Children/binary>>/binary,
"</nav>"/utf8>>;
nil ->
<<<<<<<<"<nav"/utf8, Att_str/binary>>/binary, ">"/utf8>>/binary,
Children/binary>>/binary,
"</nav>"/utf8>>
end.
-spec section(
html_dsl@types@id:id(),
html_dsl@types@class:class(),
list(attribute()),
binary()
) -> binary().
section(Id, Class, Attributes, Children) ->
Att_str = gleam@list:fold(case Id of
{id, Id@1} ->
gleam@list:append(
Attributes,
[{attribute, <<"id"/utf8>>, Id@1}]
);
nil ->
Attributes
end, <<""/utf8>>, fun(Str, A) ->
<<<<Str/binary, " "/utf8>>/binary,
(render_attribute(
{attribute,
html_dsl@utils@check:illegal_string_check(
erlang:element(2, A)
),
html_dsl@utils@check:illegal_string_check(
erlang:element(3, A)
)}
))/binary>>
end),
case Class of
{class, Class@1} ->
Class@2 = html_dsl@utils@check:illegal_string_check(Class@1),
<<<<<<<<<<<<"<section class=\""/utf8, Class@2/binary>>/binary,
"\""/utf8>>/binary,
Att_str/binary>>/binary,
">"/utf8>>/binary,
Children/binary>>/binary,
"</section>"/utf8>>;
nil ->
<<<<<<<<"<section"/utf8, Att_str/binary>>/binary, ">"/utf8>>/binary,
Children/binary>>/binary,
"</section>"/utf8>>
end.
-spec article(
html_dsl@types@id:id(),
html_dsl@types@class:class(),
list(attribute()),
binary()
) -> binary().
article(Id, Class, Attributes, Children) ->
Att_str = gleam@list:fold(case Id of
{id, Id@1} ->
gleam@list:append(
Attributes,
[{attribute, <<"id"/utf8>>, Id@1}]
);
nil ->
Attributes
end, <<""/utf8>>, fun(Str, A) ->
<<<<Str/binary, " "/utf8>>/binary,
(render_attribute(
{attribute,
html_dsl@utils@check:illegal_string_check(
erlang:element(2, A)
),
html_dsl@utils@check:illegal_string_check(
erlang:element(3, A)
)}
))/binary>>
end),
case Class of
{class, Class@1} ->
Class@2 = html_dsl@utils@check:illegal_string_check(Class@1),
<<<<<<<<<<<<"<article class=\""/utf8, Class@2/binary>>/binary,
"\""/utf8>>/binary,
Att_str/binary>>/binary,
">"/utf8>>/binary,
Children/binary>>/binary,
"</article>"/utf8>>;
nil ->
<<<<<<<<"<article"/utf8, Att_str/binary>>/binary, ">"/utf8>>/binary,
Children/binary>>/binary,
"</article>"/utf8>>
end.
-spec aside(
html_dsl@types@id:id(),
html_dsl@types@class:class(),
list(attribute()),
binary()
) -> binary().
aside(Id, Class, Attributes, Children) ->
Att_str = gleam@list:fold(case Id of
{id, Id@1} ->
gleam@list:append(
Attributes,
[{attribute, <<"id"/utf8>>, Id@1}]
);
nil ->
Attributes
end, <<""/utf8>>, fun(Str, A) ->
<<<<Str/binary, " "/utf8>>/binary,
(render_attribute(
{attribute,
html_dsl@utils@check:illegal_string_check(
erlang:element(2, A)
),
html_dsl@utils@check:illegal_string_check(
erlang:element(3, A)
)}
))/binary>>
end),
case Class of
{class, Class@1} ->
Class@2 = html_dsl@utils@check:illegal_string_check(Class@1),
<<<<<<<<<<<<"<aside class=\""/utf8, Class@2/binary>>/binary,
"\""/utf8>>/binary,
Att_str/binary>>/binary,
">"/utf8>>/binary,
Children/binary>>/binary,
"</aside>"/utf8>>;
nil ->
<<<<<<<<"<aside"/utf8, Att_str/binary>>/binary, ">"/utf8>>/binary,
Children/binary>>/binary,
"</aside>"/utf8>>
end.
-spec main(
html_dsl@types@id:id(),
html_dsl@types@class:class(),
list(attribute()),
binary()
) -> binary().
main(Id, Class, Attributes, Children) ->
Att_str = gleam@list:fold(case Id of
{id, Id@1} ->
gleam@list:append(
Attributes,
[{attribute, <<"id"/utf8>>, Id@1}]
);
nil ->
Attributes
end, <<""/utf8>>, fun(Str, A) ->
<<<<Str/binary, " "/utf8>>/binary,
(render_attribute(
{attribute,
html_dsl@utils@check:illegal_string_check(
erlang:element(2, A)
),
html_dsl@utils@check:illegal_string_check(
erlang:element(3, A)
)}
))/binary>>
end),
case Class of
{class, Class@1} ->
Class@2 = html_dsl@utils@check:illegal_string_check(Class@1),
<<<<<<<<<<<<"<main class=\""/utf8, Class@2/binary>>/binary,
"\""/utf8>>/binary,
Att_str/binary>>/binary,
">"/utf8>>/binary,
Children/binary>>/binary,
"</main>"/utf8>>;
nil ->
<<<<<<<<"<main"/utf8, Att_str/binary>>/binary, ">"/utf8>>/binary,
Children/binary>>/binary,
"</main>"/utf8>>
end.
-spec button(
html_dsl@types@id:id(),
html_dsl@types@class:class(),
list(attribute()),
binary()
) -> binary().
button(Id, Class, Attributes, Children) ->
Att_str = gleam@list:fold(case Id of
{id, Id@1} ->
gleam@list:append(
Attributes,
[{attribute, <<"id"/utf8>>, Id@1}]
);
nil ->
Attributes
end, <<""/utf8>>, fun(Str, A) ->
<<<<Str/binary, " "/utf8>>/binary,
(render_attribute(
{attribute,
html_dsl@utils@check:illegal_string_check(
erlang:element(2, A)
),
html_dsl@utils@check:illegal_string_check(
erlang:element(3, A)
)}
))/binary>>
end),
case Class of
{class, Class@1} ->
Class@2 = html_dsl@utils@check:illegal_string_check(Class@1),
<<<<<<<<<<<<"<button class=\""/utf8, Class@2/binary>>/binary,
"\""/utf8>>/binary,
Att_str/binary>>/binary,
">"/utf8>>/binary,
Children/binary>>/binary,
"</button>"/utf8>>;
nil ->
<<<<<<<<"<button"/utf8, Att_str/binary>>/binary, ">"/utf8>>/binary,
Children/binary>>/binary,
"</button>"/utf8>>
end.
-spec select(
html_dsl@types@id:id(),
html_dsl@types@class:class(),
list(attribute()),
list(option())
) -> binary().
select(Id, Class, Attributes, Options) ->
Att_str = gleam@list:fold(case Id of
{id, Id@1} ->
gleam@list:append(
Attributes,
[{attribute, <<"id"/utf8>>, Id@1}]
);
nil ->
Attributes
end, <<""/utf8>>, fun(Str, A) ->
<<<<Str/binary, " "/utf8>>/binary,
(render_attribute(
{attribute,
html_dsl@utils@check:illegal_string_check(
erlang:element(2, A)
),
html_dsl@utils@check:illegal_string_check(
erlang:element(3, A)
)}
))/binary>>
end),
Options_str = gleam@list:fold(
Options,
<<""/utf8>>,
fun(Str@1, Option) -> <<Str@1/binary, (case Option of
{option, Child} ->
Child
end)/binary>> end
),
case Class of
{class, Class@1} ->
Class@2 = html_dsl@utils@check:illegal_string_check(Class@1),
<<<<<<<<<<<<"<select class=\""/utf8, Class@2/binary>>/binary,
"\""/utf8>>/binary,
Att_str/binary>>/binary,
">"/utf8>>/binary,
Options_str/binary>>/binary,
"</select>"/utf8>>;
nil ->
<<<<<<<<"<select"/utf8, Att_str/binary>>/binary, ">"/utf8>>/binary,
Options_str/binary>>/binary,
"</select>"/utf8>>
end.
-spec option(binary(), binary()) -> option().
option(Value, Children) ->
Value@1 = html_dsl@utils@check:illegal_string_check(Value),
{option,
<<<<<<<<"<option value=\""/utf8, Value@1/binary>>/binary, "\">"/utf8>>/binary,
Children/binary>>/binary,
"</option>"/utf8>>}.