-module(htmb). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]). -export([escape/1, dangerous_unescaped_fragment/1, text/1, render/1, render_page/1, h/3]). -export_type([html/0]). -type html() :: any(). -file("/Users/louis/src/gleam/htmb/src/htmb.gleam", 79). -spec do_escape(binary(), binary()) -> binary(). do_escape(Escaped, Content) -> case gleam_stdlib:string_pop_grapheme(Content) of {ok, {<<"<"/utf8>>, Xs}} -> do_escape(<>, Xs); {ok, {<<">"/utf8>>, Xs@1}} -> do_escape(<>, Xs@1); {ok, {<<"&"/utf8>>, Xs@2}} -> do_escape(<>, Xs@2); {ok, {X, Xs@3}} -> do_escape(<>, Xs@3); {error, _} -> <> end. -file("/Users/louis/src/gleam/htmb/src/htmb.gleam", 75). -spec escape(binary()) -> binary(). escape(Content) -> do_escape(<<""/utf8>>, Content). -file("/Users/louis/src/gleam/htmb/src/htmb.gleam", 94). -spec attribute(binary(), {binary(), binary()}) -> binary(). attribute(Content, Attribute) -> <<<<<<<<<>/binary, (erlang:element(1, Attribute))/binary>>/binary, "=\""/utf8>>/binary, (erlang:element(2, Attribute))/binary>>/binary, "\""/utf8>>. -file("/Users/louis/src/gleam/htmb/src/htmb.gleam", 104). -spec dangerous_unescaped_fragment(gleam@string_tree:string_tree()) -> html(). dangerous_unescaped_fragment(S) -> htmb_ffi:identity(S). -file("/Users/louis/src/gleam/htmb/src/htmb.gleam", 68). -spec text(binary()) -> html(). text(Content) -> _pipe = Content, _pipe@1 = do_escape(<<""/utf8>>, _pipe), _pipe@2 = gleam_stdlib:identity(_pipe@1), htmb_ffi:identity(_pipe@2). -file("/Users/louis/src/gleam/htmb/src/htmb.gleam", 108). -spec render(html()) -> gleam@string_tree:string_tree(). render(Element) -> htmb_ffi:identity(Element). -file("/Users/louis/src/gleam/htmb/src/htmb.gleam", 89). -spec render_page(html()) -> gleam@string_tree:string_tree(). render_page(Html) -> _pipe = htmb_ffi:identity(Html), gleam@string_tree:prepend(_pipe, <<""/utf8>>). -file("/Users/louis/src/gleam/htmb/src/htmb.gleam", 98). -spec child(gleam@string_tree:string_tree(), html()) -> gleam@string_tree:string_tree(). child(Siblings, Child) -> gleam_stdlib:iodata_append(Siblings, htmb_ffi:identity(Child)). -file("/Users/louis/src/gleam/htmb/src/htmb.gleam", 28). -spec h(binary(), list({binary(), binary()}), list(html())) -> html(). h(Tag, Attributes, Children) -> Opening = begin _pipe = <<"<"/utf8>>, _pipe@1 = gleam@string:append(_pipe, Tag), _pipe@2 = gleam@list:fold(Attributes, _pipe@1, fun attribute/2), _pipe@3 = gleam@string:append(_pipe@2, <<">"/utf8>>), gleam_stdlib:identity(_pipe@3) end, _pipe@6 = case Tag of <<"area"/utf8>> -> Opening; <<"base"/utf8>> -> Opening; <<"br"/utf8>> -> Opening; <<"col"/utf8>> -> Opening; <<"command"/utf8>> -> Opening; <<"embed"/utf8>> -> Opening; <<"hr"/utf8>> -> Opening; <<"img"/utf8>> -> Opening; <<"input"/utf8>> -> Opening; <<"keygen"/utf8>> -> Opening; <<"link"/utf8>> -> Opening; <<"meta"/utf8>> -> Opening; <<"param"/utf8>> -> Opening; <<"source"/utf8>> -> Opening; <<"track"/utf8>> -> Opening; <<"wbr"/utf8>> -> Opening; _ -> _pipe@4 = Opening, _pipe@5 = gleam@list:fold(Children, _pipe@4, fun child/2), gleam@string_tree:append( _pipe@5, <<<<">/binary, ">"/utf8>> ) end, htmb_ffi:identity(_pipe@6).