Packages
lustre
3.0.0-rc.4
5.7.1
5.7.0
5.6.0
5.5.2
5.5.1
5.5.0
5.4.0
5.3.5
5.3.4
5.3.3
5.3.2
5.3.1
5.3.0
5.2.1
5.2.0
5.1.1
5.1.0
5.0.3
5.0.2
5.0.1
5.0.0
4.6.4
4.6.3
4.6.2
4.6.1
4.6.0
4.5.1
4.5.0
4.4.4
4.4.3
4.4.1
4.4.0
4.3.6
4.3.5
4.3.4
4.3.3
4.3.2
4.3.1
4.3.0
4.2.6
4.2.5
4.2.4
4.2.3
4.2.2
4.2.1
4.2.0
4.1.8
4.1.7
4.1.6
4.1.5
4.1.4
4.1.3
4.1.2
4.1.1
4.1.0
4.0.0
4.0.0-rc1
4.0.0-rc.2
3.1.4
3.1.3
3.1.2
3.1.1
3.1.0
3.0.12
3.0.11
3.0.10
3.0.9
3.0.8
3.0.7
3.0.6
3.0.5
3.0.4
3.0.3
3.0.2
3.0.1
3.0.0
3.0.0-rc.8
3.0.0-rc.7
3.0.0-rc.6
3.0.0-rc.5
3.0.0-rc.4
3.0.0-rc.3
3.0.0-rc.2
3.0.0-rc.1
2.0.1
2.0.0
1.3.0
1.2.0
1.1.0
1.0.0
Create HTML templates, single page applications, Web Components, and real-time server components in Gleam!
Current section
Files
Jump to
Current section
Files
src/lustre@attribute.erl
-module(lustre@attribute).
-compile([no_auto_import, nowarn_unused_vars]).
-export([attribute/2, class/1, classes/1, id/1, type_/1, value/1, checked/1, placeholder/1, selected/1, accept/1, accept_charset/1, msg/1, autocomplete/1, autofocus/1, disabled/1, name/1, pattern/1, readonly/1, required/1, for/1, max/1, min/1, step/1, cols/1, rows/1, wrap/1, href/1, target/1, download/1, rel/1, src/1, height/1, width/1, alt/1, autoplay/1, controls/1, loop/1, style/1]).
-export_type([attribute/1]).
-type attribute(Msg) :: any() | {gleam_phantom, Msg}.
-spec attribute(binary(), any()) -> attribute(any()).
attribute(Field@0, Field@1) ->
'../lustre.ffi.mjs':attr(Field@0, Field@1).
-spec class(binary()) -> attribute(any()).
class(Name) ->
'..@lustre.ffi.mjs':attr(<<"class"/utf8>>, Name).
-spec classes(list({binary(), boolean()})) -> attribute(any()).
classes(Names) ->
'..@lustre.ffi.mjs':attr(
<<"class"/utf8>>,
begin
_pipe = Names,
_pipe@1 = gleam@list:filter_map(
_pipe,
fun(Class) -> case erlang:element(2, Class) of
true ->
{ok, erlang:element(1, Class)};
false ->
{error, nil}
end end
),
gleam@string:join(_pipe@1, <<" "/utf8>>)
end
).
-spec id(binary()) -> attribute(any()).
id(Name) ->
'..@lustre.ffi.mjs':attr(<<"id"/utf8>>, Name).
-spec type_(binary()) -> attribute(any()).
type_(Name) ->
'..@lustre.ffi.mjs':attr(<<"type"/utf8>>, Name).
-spec value(gleam@dynamic:dynamic()) -> attribute(any()).
value(Val) ->
'..@lustre.ffi.mjs':attr(<<"value"/utf8>>, Val).
-spec checked(boolean()) -> attribute(any()).
checked(Is_checked) ->
'..@lustre.ffi.mjs':attr(<<"checked"/utf8>>, Is_checked).
-spec placeholder(binary()) -> attribute(any()).
placeholder(Text) ->
'..@lustre.ffi.mjs':attr(<<"placeholder"/utf8>>, Text).
-spec selected(boolean()) -> attribute(any()).
selected(Is_selected) ->
'..@lustre.ffi.mjs':attr(<<"selected"/utf8>>, Is_selected).
-spec accept(list(binary())) -> attribute(any()).
accept(Types) ->
'..@lustre.ffi.mjs':attr(
<<"accept"/utf8>>,
gleam@string:join(Types, <<" "/utf8>>)
).
-spec accept_charset(list(binary())) -> attribute(any()).
accept_charset(Types) ->
'..@lustre.ffi.mjs':attr(
<<"acceptCharset"/utf8>>,
gleam@string:join(Types, <<" "/utf8>>)
).
-spec msg(binary()) -> attribute(any()).
msg(Uri) ->
'..@lustre.ffi.mjs':attr(<<"msg"/utf8>>, Uri).
-spec autocomplete(binary()) -> attribute(any()).
autocomplete(Name) ->
'..@lustre.ffi.mjs':attr(<<"autocomplete"/utf8>>, Name).
-spec autofocus(boolean()) -> attribute(any()).
autofocus(Should_autofocus) ->
'..@lustre.ffi.mjs':attr(<<"autoFocus"/utf8>>, Should_autofocus).
-spec disabled(boolean()) -> attribute(any()).
disabled(Is_disabled) ->
'..@lustre.ffi.mjs':attr(<<"disabled"/utf8>>, Is_disabled).
-spec name(binary()) -> attribute(any()).
name(Name) ->
'..@lustre.ffi.mjs':attr(<<"name"/utf8>>, Name).
-spec pattern(binary()) -> attribute(any()).
pattern(Regex) ->
'..@lustre.ffi.mjs':attr(<<"pattern"/utf8>>, Regex).
-spec readonly(boolean()) -> attribute(any()).
readonly(Is_readonly) ->
'..@lustre.ffi.mjs':attr(<<"readonly"/utf8>>, Is_readonly).
-spec required(boolean()) -> attribute(any()).
required(Is_required) ->
'..@lustre.ffi.mjs':attr(<<"required"/utf8>>, Is_required).
-spec for(binary()) -> attribute(any()).
for(Id) ->
'..@lustre.ffi.mjs':attr(<<"htmlFor"/utf8>>, Id).
-spec max(binary()) -> attribute(any()).
max(Val) ->
'..@lustre.ffi.mjs':attr(<<"max"/utf8>>, Val).
-spec min(binary()) -> attribute(any()).
min(Val) ->
'..@lustre.ffi.mjs':attr(<<"min"/utf8>>, Val).
-spec step(binary()) -> attribute(any()).
step(Val) ->
'..@lustre.ffi.mjs':attr(<<"step"/utf8>>, Val).
-spec cols(integer()) -> attribute(any()).
cols(Val) ->
'..@lustre.ffi.mjs':attr(<<"cols"/utf8>>, gleam@int:to_string(Val)).
-spec rows(integer()) -> attribute(any()).
rows(Val) ->
'..@lustre.ffi.mjs':attr(<<"rows"/utf8>>, gleam@int:to_string(Val)).
-spec wrap(binary()) -> attribute(any()).
wrap(Mode) ->
'..@lustre.ffi.mjs':attr(<<"wrap"/utf8>>, Mode).
-spec href(binary()) -> attribute(any()).
href(Uri) ->
'..@lustre.ffi.mjs':attr(<<"href"/utf8>>, Uri).
-spec target(binary()) -> attribute(any()).
target(Target) ->
'..@lustre.ffi.mjs':attr(<<"target"/utf8>>, Target).
-spec download(binary()) -> attribute(any()).
download(Filename) ->
'..@lustre.ffi.mjs':attr(<<"download"/utf8>>, Filename).
-spec rel(binary()) -> attribute(any()).
rel(Relationship) ->
'..@lustre.ffi.mjs':attr(<<"rel"/utf8>>, Relationship).
-spec src(binary()) -> attribute(any()).
src(Uri) ->
'..@lustre.ffi.mjs':attr(<<"src"/utf8>>, Uri).
-spec height(integer()) -> attribute(any()).
height(Val) ->
'..@lustre.ffi.mjs':attr(<<"height"/utf8>>, gleam@int:to_string(Val)).
-spec width(integer()) -> attribute(any()).
width(Val) ->
'..@lustre.ffi.mjs':attr(<<"width"/utf8>>, gleam@int:to_string(Val)).
-spec alt(binary()) -> attribute(any()).
alt(Text) ->
'..@lustre.ffi.mjs':attr(<<"alt"/utf8>>, Text).
-spec autoplay(boolean()) -> attribute(any()).
autoplay(Should_autoplay) ->
'..@lustre.ffi.mjs':attr(<<"autoplay"/utf8>>, Should_autoplay).
-spec controls(boolean()) -> attribute(any()).
controls(Visible) ->
'..@lustre.ffi.mjs':attr(<<"controls"/utf8>>, Visible).
-spec loop(boolean()) -> attribute(any()).
loop(Should_loop) ->
'..@lustre.ffi.mjs':attr(<<"loop"/utf8>>, Should_loop).
-spec style(list({binary(), binary()})) -> attribute(any()).
style(Properties) ->
'..@lustre.ffi.mjs':attr(
<<"style"/utf8>>,
'..@lustre.ffi.mjs':styles(Properties)
).