Packages

A DSL for generating HTML in Gleam

Current section

Files

Jump to
html_dsl src html_dsl.erl
Raw

src/html_dsl.erl

-module(html_dsl).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-export([main/0]).
-spec main() -> nil.
main() ->
_pipe = html_dsl@types@html:html(
<<"en"/utf8>>,
<<(html_dsl@types@html:head(
[html_dsl@types@html:title(<<"Hello, Gleam!"/utf8>>),
html_dsl@types@html:meta(
<<"viewport"/utf8>>,
<<"width=device-width, initial-scale=1"/utf8>>
),
html_dsl@types@html:meta(
<<"description"/utf8>>,
<<"Some website"/utf8>>
),
html_dsl@types@html:charset(<<"utf-8"/utf8>>)]
))/binary,
(html_dsl@types@html:body(
{id, <<"main-content"/utf8>>},
{class, <<"grid"/utf8>>},
[],
<<<<(html_dsl@types@html:h1(
nil,
nil,
[],
<<"Hello, Gleam!"/utf8>>
))/binary,
(html_dsl@types@html:ul(
nil,
nil,
[],
[html_dsl@types@html:li(
nil,
nil,
[],
<<"This is a list item"/utf8>>
),
html_dsl@types@html:li(
nil,
nil,
[],
<<"This is another list item"/utf8>>
)]
))/binary>>/binary,
(html_dsl@types@html:form(
nil,
nil,
[],
[html_dsl@types@html:label(
nil,
nil,
[],
<<"Name:"/utf8>>
),
html_dsl@types@html:input(
nil,
nil,
[],
text,
<<"name"/utf8>>
),
html_dsl@types@html:input(
nil,
nil,
[],
submit,
<<"submit"/utf8>>
),
html_dsl@types@html:new_element(
html_dsl@types@html:button(
nil,
nil,
[],
<<"Click me!"/utf8>>
)
)]
))/binary>>
))/binary>>
),
_pipe@1 = html_dsl@types@html:html_to_string(_pipe),
gleam@io:println(_pipe@1).