datastar/ds_lustre

This module provides functions to add Datastar data attributes to html elements as shown here https://data-star.dev/reference/attributes

Values

pub fn data_attr(
  key: String,
  expression: String,
) -> @internal Attribute(a)

Sets the value of any HTML attribute to an expression, and keeps it in sync.

See https://data-star.dev/reference/attributes#data-attr.

e.g.

div([ds_lustre.data_attr("title", "$foo")], [])
<div data-attr-title="$foo"></div>
pub fn data_attrs(
  pairs: List(#(String, String)),
) -> @internal Attribute(a)

Similar to data_attr but sets multiple attrs at once.

See https://data-star.dev/reference/attributes#data-attr

e.g.

<div data-attr="{title: $foo, disabled: $bar}"></div>
pub fn data_bind(value: String) -> @internal Attribute(a)

Creates a signal and sets up two-way data binding. This takes the name of a signal (without the $).

See https://data-star.dev/reference/attributes#data-bind

ds_lustre.data_bind("first_name")
<input data-bind="first_name" />
pub fn data_class(
  key: String,
  expression: String,
) -> @internal Attribute(a)

Adds or removes a class.

See https://data-star.dev/reference/attributes#data-class

The first value is the class name.

The second value is an expression. e.g. a signal $selected or a complex expression

pub fn data_classes(
  pairs: List(#(String, String)),
) -> @internal Attribute(a)

Control multiple classes at once

See https://data-star.dev/reference/attributes#data-class

pub fn data_computed(
  key: String,
  value: String,
) -> @internal Attribute(a)

Creates a signal that is computed based on an expression.

See https://data-star.dev/reference/attributes#data-computed

pub fn data_indicator(signal: String) -> @internal Attribute(a)
pub fn data_on(
  event: String,
  expression: String,
) -> @internal Attribute(a)

Attaches an event listener to an element.

See https://data-star.dev/reference/attributes#data-on

pub fn data_on_click(
  expression: String,
) -> @internal Attribute(a)

Shorcut for data_on("click", _).

pub fn data_on_submit(
  expression: String,
) -> @internal Attribute(a)

Shorcut for data_on("submit", _).

This prevents the default submission behavior of forms.

pub fn data_ref(value: String) -> @internal Attribute(a)

Creates a signal that is a reference to this DOM element.

See https://data-star.dev/reference/attributes#data-ref

pub fn data_show(value: String) -> @internal Attribute(a)

Show or hides an element based on an expression.

See https://data-star.dev/reference/attributes#data-show

pub fn data_signal(
  signal: String,
  value: String,
) -> @internal Attribute(a)

Patches one signals into the existing signals.

See https://data-star.dev/reference/attributes#data-signals

pub fn data_signals(
  signals: List(#(String, json.Json)),
) -> @internal Attribute(a)

Merges one or more signals into the existing signals.

See https://data-star.dev/reference/attributes#data-signals

pub fn data_text(value: String) -> @internal Attribute(a)

Binds the text content of an element to an expression.

See https://data-star.dev/reference/attributes#data-text

e.g.

<div data-text="$foo"></div>
Search Document