aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHayleigh Thompson <me@hayleigh.dev>2023-10-21 17:16:48 +0100
committerHayleigh Thompson <me@hayleigh.dev>2023-10-21 17:16:48 +0100
commitff903ab203a5371dffe5e3dd2e69e5e4fb8af027 (patch)
tree06321f65b974824a4aeb32efe2068d98b044b225
parent728041fb5adf33b2db33d3fcf7e5988887eca7cf (diff)
downloadlustre-ff903ab203a5371dffe5e3dd2e69e5e4fb8af027.tar.gz
lustre-ff903ab203a5371dffe5e3dd2e69e5e4fb8af027.zip
:bug: Fixed bug where attribute.to_string_builder didnt emit bool attributes properly.
-rw-r--r--src/lustre/attribute.gleam5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/lustre/attribute.gleam b/src/lustre/attribute.gleam
index 3b7ec70..e71636c 100644
--- a/src/lustre/attribute.gleam
+++ b/src/lustre/attribute.gleam
@@ -91,7 +91,7 @@ pub fn to_string_parts(attr: Attribute(msg)) -> Result(#(String, String), Nil) {
///
pub fn to_string_builder(attr: Attribute(msg)) -> StringBuilder {
case attr {
- Attribute(name, value, as_property: False) -> {
+ Attribute(name, value, as_property) -> {
case dynamic.classify(value) {
"String" ->
[name, "=\"", dynamic.unsafe_coerce(value), "\""]
@@ -106,13 +106,12 @@ pub fn to_string_builder(attr: Attribute(msg)) -> StringBuilder {
False -> string_builder.new()
}
- // For everything else we'll just make a best-effort serialisation.
+ _ if as_property -> string_builder.new()
_ ->
[name, "=\"", string.inspect(value), "\""]
|> string_builder.from_strings
}
}
- Attribute(_, _, as_property: True) -> string_builder.new()
Event(on, _) ->
["data-lustre-on:", on]
|> string_builder.from_strings