Current section
Files
Jump to
Current section
Files
src/sprocket@html@attributes.erl
-module(sprocket@html@attributes).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-export([attribute/2, event/2, client_hook/2, on_click/1, on_doubleclick/1, on_change/1, on_input/1, media/1, role/1, xmlns/1, xmlns_xlink/1, accept/1, accept_charset/1, action/1, alt/1, async/0, autocapitalize/1, autocomplete/1, autofocus/0, autoplay/0, capture/1, charset/1, checked/0, cite/1, class/1, classes/1, content/1, contenteditable/0, crossorigin/1, defer/0, disabled/0, draggable/0, for/1, formaction/1, height/1, href/1, http_equiv/1, id/1, input_type/1, integrity/1, lang/1, loop/0, method/1, name/1, placeholder/1, preload/0, property/1, readonly/0, referrerpolicy/1, rel/1, selected/0, src/1, style/1, tabindex/1, target/1, title/1, value/1, width/1]).
-spec attribute(binary(), any()) -> sprocket@context:attribute().
attribute(Name, Value) ->
{attribute, Name, gleam@dynamic:from(Value)}.
-spec event(binary(), sprocket@context:identifiable_handler()) -> sprocket@context:attribute().
event(Name, Handler) ->
{event, Name, Handler}.
-spec client_hook(sprocket@internal@utils@unique:unique(), binary()) -> sprocket@context:attribute().
client_hook(Id, Name) ->
{client_hook, Id, Name}.
-spec on_click(sprocket@context:identifiable_handler()) -> sprocket@context:attribute().
on_click(Handler) ->
event(<<"click"/utf8>>, Handler).
-spec on_doubleclick(sprocket@context:identifiable_handler()) -> sprocket@context:attribute().
on_doubleclick(Handler) ->
event(<<"doubleclick"/utf8>>, Handler).
-spec on_change(sprocket@context:identifiable_handler()) -> sprocket@context:attribute().
on_change(Handler) ->
event(<<"change"/utf8>>, Handler).
-spec on_input(sprocket@context:identifiable_handler()) -> sprocket@context:attribute().
on_input(Handler) ->
event(<<"input"/utf8>>, Handler).
-spec media(binary()) -> sprocket@context:attribute().
media(Value) ->
attribute(<<"media"/utf8>>, Value).
-spec role(binary()) -> sprocket@context:attribute().
role(Value) ->
attribute(<<"role"/utf8>>, Value).
-spec xmlns(binary()) -> sprocket@context:attribute().
xmlns(Value) ->
attribute(<<"xmlns"/utf8>>, Value).
-spec xmlns_xlink(binary()) -> sprocket@context:attribute().
xmlns_xlink(Value) ->
attribute(<<"xmlns_xlink"/utf8>>, Value).
-spec accept(binary()) -> sprocket@context:attribute().
accept(Value) ->
attribute(<<"accept"/utf8>>, Value).
-spec accept_charset(binary()) -> sprocket@context:attribute().
accept_charset(Value) ->
attribute(<<"accept-charset"/utf8>>, Value).
-spec action(binary()) -> sprocket@context:attribute().
action(Value) ->
attribute(<<"action"/utf8>>, Value).
-spec alt(binary()) -> sprocket@context:attribute().
alt(Value) ->
attribute(<<"alt"/utf8>>, Value).
-spec async() -> sprocket@context:attribute().
async() ->
attribute(<<"async"/utf8>>, <<"true"/utf8>>).
-spec autocapitalize(binary()) -> sprocket@context:attribute().
autocapitalize(Value) ->
attribute(<<"autocapitalize"/utf8>>, Value).
-spec autocomplete(binary()) -> sprocket@context:attribute().
autocomplete(Value) ->
attribute(<<"autocomplete"/utf8>>, Value).
-spec autofocus() -> sprocket@context:attribute().
autofocus() ->
attribute(<<"autofocus"/utf8>>, <<"true"/utf8>>).
-spec autoplay() -> sprocket@context:attribute().
autoplay() ->
attribute(<<"autoplay"/utf8>>, <<"true"/utf8>>).
-spec capture(binary()) -> sprocket@context:attribute().
capture(Value) ->
attribute(<<"capture"/utf8>>, Value).
-spec charset(binary()) -> sprocket@context:attribute().
charset(Value) ->
attribute(<<"charset"/utf8>>, Value).
-spec checked() -> sprocket@context:attribute().
checked() ->
attribute(<<"checked"/utf8>>, <<"true"/utf8>>).
-spec cite(binary()) -> sprocket@context:attribute().
cite(Value) ->
attribute(<<"cite"/utf8>>, Value).
-spec class(binary()) -> sprocket@context:attribute().
class(Value) ->
attribute(<<"class"/utf8>>, Value).
-spec classes(list(gleam@option:option(binary()))) -> sprocket@context:attribute().
classes(Value) ->
attribute(
<<"class"/utf8>>,
begin
_pipe = gleam@list:fold(
Value,
gleam@string_builder:new(),
fun(Sb, V) -> case V of
none ->
Sb;
{some, V@1} ->
case gleam@string_builder:is_empty(Sb) of
true ->
gleam@string_builder:append(Sb, V@1);
false ->
gleam@string_builder:append(
Sb,
<<" "/utf8, V@1/binary>>
)
end
end end
),
gleam@string_builder:to_string(_pipe)
end
).
-spec content(binary()) -> sprocket@context:attribute().
content(Value) ->
attribute(<<"content"/utf8>>, Value).
-spec contenteditable() -> sprocket@context:attribute().
contenteditable() ->
attribute(<<"contenteditable"/utf8>>, <<"true"/utf8>>).
-spec crossorigin(binary()) -> sprocket@context:attribute().
crossorigin(Value) ->
attribute(<<"crossorigin"/utf8>>, Value).
-spec defer() -> sprocket@context:attribute().
defer() ->
attribute(<<"defer"/utf8>>, <<"true"/utf8>>).
-spec disabled() -> sprocket@context:attribute().
disabled() ->
attribute(<<"disabled"/utf8>>, <<"true"/utf8>>).
-spec draggable() -> sprocket@context:attribute().
draggable() ->
attribute(<<"draggable"/utf8>>, <<"true"/utf8>>).
-spec for(binary()) -> sprocket@context:attribute().
for(Value) ->
attribute(<<"for"/utf8>>, Value).
-spec formaction(binary()) -> sprocket@context:attribute().
formaction(Value) ->
attribute(<<"formaction"/utf8>>, Value).
-spec height(binary()) -> sprocket@context:attribute().
height(Value) ->
attribute(<<"height"/utf8>>, Value).
-spec href(binary()) -> sprocket@context:attribute().
href(Value) ->
attribute(<<"href"/utf8>>, Value).
-spec http_equiv(binary()) -> sprocket@context:attribute().
http_equiv(Value) ->
attribute(<<"http-equiv"/utf8>>, Value).
-spec id(binary()) -> sprocket@context:attribute().
id(Value) ->
attribute(<<"id"/utf8>>, Value).
-spec input_type(binary()) -> sprocket@context:attribute().
input_type(Value) ->
attribute(<<"type"/utf8>>, Value).
-spec integrity(binary()) -> sprocket@context:attribute().
integrity(Value) ->
attribute(<<"integrity"/utf8>>, Value).
-spec lang(binary()) -> sprocket@context:attribute().
lang(Value) ->
attribute(<<"lang"/utf8>>, Value).
-spec loop() -> sprocket@context:attribute().
loop() ->
attribute(<<"loop"/utf8>>, <<"true"/utf8>>).
-spec method(binary()) -> sprocket@context:attribute().
method(Value) ->
attribute(<<"method"/utf8>>, Value).
-spec name(binary()) -> sprocket@context:attribute().
name(Value) ->
attribute(<<"name"/utf8>>, Value).
-spec placeholder(binary()) -> sprocket@context:attribute().
placeholder(Value) ->
attribute(<<"placeholder"/utf8>>, Value).
-spec preload() -> sprocket@context:attribute().
preload() ->
attribute(<<"preload"/utf8>>, <<"true"/utf8>>).
-spec property(binary()) -> sprocket@context:attribute().
property(Value) ->
attribute(<<"property"/utf8>>, Value).
-spec readonly() -> sprocket@context:attribute().
readonly() ->
attribute(<<"readonly"/utf8>>, <<"true"/utf8>>).
-spec referrerpolicy(binary()) -> sprocket@context:attribute().
referrerpolicy(Value) ->
attribute(<<"referrerpolicy"/utf8>>, Value).
-spec rel(binary()) -> sprocket@context:attribute().
rel(Value) ->
attribute(<<"rel"/utf8>>, Value).
-spec selected() -> sprocket@context:attribute().
selected() ->
attribute(<<"selected"/utf8>>, <<"true"/utf8>>).
-spec src(binary()) -> sprocket@context:attribute().
src(Value) ->
attribute(<<"src"/utf8>>, Value).
-spec style(binary()) -> sprocket@context:attribute().
style(Value) ->
attribute(<<"style"/utf8>>, Value).
-spec tabindex(binary()) -> sprocket@context:attribute().
tabindex(Value) ->
attribute(<<"tabindex"/utf8>>, Value).
-spec target(binary()) -> sprocket@context:attribute().
target(Value) ->
attribute(<<"target"/utf8>>, Value).
-spec title(binary()) -> sprocket@context:attribute().
title(Value) ->
attribute(<<"title"/utf8>>, Value).
-spec value(binary()) -> sprocket@context:attribute().
value(Value) ->
attribute(<<"value"/utf8>>, Value).
-spec width(binary()) -> sprocket@context:attribute().
width(Value) ->
attribute(<<"width"/utf8>>, Value).