Closed bgwdotdev closed 1 month ago
Potentially related to #125, thanks for flagging it :)
the html output doesn't seem to include the attributes,
Can you clarify whether you mean the static HTML string (eg from calling element.to_string
) or do you mean the HTML in your browser's dev tools in a running app.
i'm using element.to_string.
from the following code:
let _ =
io.debug(
audio([attribute.autoplay(True)], [
source([src("some.mp3"), type_("audio/mpeg")]),
]),
)
|> element.to_string()
|> io.debug()
here's the debug output
Element("", "", "audio", [Attribute("autoplay", True, True)], [Element("", "", "source", [Attribute("src", "some.mp3", False), Attribute("type", "audio/mpeg", False)], [], False, True)], False, False)
"<audio><source src=\"some.mp3\" type=\"audio/mpeg\"></audio>"
Can you make sure you run gleam deps update
. I cannot reproduce this:
Element("", "", "audio", [Attribute("autoplay", True, True)], [Element("", "", "source", [Attribute("src", "some.mp3", False), Attribute("type", "audio/mpeg", False)], [], False, True)], False, False)
"<audio autoplay><source src=\"some.mp3\" type=\"audio/mpeg\"></audio>"
bizarre. Definitely on 4.2.0. Still seeing the issue. Setup test with this:
gleam new lustre_test_audio
cd lustre_test_audio
gleam add lustre
cat > src/lustre_test_audio.gleam << EOF
import gleam/io
import lustre/attribute
import lustre/element
import lustre/element/html
pub fn main() {
let _ =
io.debug(
html.audio([attribute.autoplay(True)], [
html.source([attribute.src("some.mp3"), attribute.type_("audio/mpeg")]),
]),
)
|> element.to_string()
|> io.debug()
}
EOF
gleam run --target erlang
gleam run --target javascript
manifest looks like this:
# This file was generated by Gleam
# You typically do not need to edit this file
packages = [
{ name = "gleam_erlang", version = "0.25.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_erlang", source = "hex", outer_checksum = "054D571A7092D2A9727B3E5D183B7507DAB0DA41556EC9133606F09C15497373" },
{ name = "gleam_json", version = "1.0.1", build_tools = ["gleam"], requirements = ["gleam_stdlib", "thoas"], otp_app = "gleam_json", source = "hex", outer_checksum = "9063D14D25406326C0255BDA0021541E797D8A7A12573D849462CAFED459F6EB" },
{ name = "gleam_otp", version = "0.10.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_stdlib"], otp_app = "gleam_otp", source = "hex", outer_checksum = "0B04FE915ACECE539B317F9652CAADBBC0F000184D586AAAF2D94C100945D72B" },
{ name = "gleam_stdlib", version = "0.37.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "5398BD6C2ABA17338F676F42F404B9B7BABE1C8DC7380031ACB05BBE1BCF3742" },
{ name = "gleeunit", version = "1.1.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "72CDC3D3F719478F26C4E2C5FED3E657AC81EC14A47D2D2DEBB8693CA3220C3B" },
{ name = "lustre", version = "4.2.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_json", "gleam_otp", "gleam_stdlib"], otp_app = "lustre", source = "hex", outer_checksum = "258F876CD7AB12C2C773F1A30F76DFC0A0ED989B720070DF32FC0717A6A0E60C" },
{ name = "thoas", version = "1.2.0", build_tools = ["rebar3"], requirements = [], otp_app = "thoas", source = "hex", outer_checksum = "540C8CB7D9257F2AD0A14145DC23560F91ACDCA995F0CCBA779EB33AF5D859D1" },
]
[requirements]
gleam_stdlib = { version = ">= 0.34.0 and < 2.0.0" }
gleeunit = { version = ">= 1.0.0 and < 2.0.0" }
lustre = { version = ">= 4.2.0 and < 5.0.0"}
if it helps any, here's a tar of the above too in-case you experience something different. lustre_test_audio.tar.gz
Ah I've discovered the bug. That was bloody tricky that.
In the standard library 0.36.0, dynamic.classify
returned "Atom"
for bools on erlang and "Boolean"
for bools on javascript. This is the version the repo's manifest.toml has (packages don't have a manifest when published)
0.37.0 changes this and instead of "Atom"
classify now classifies bools as "Bool"
. So we were never catching it.
v4.2.1 should be published in a couple of minutes, could you give it a try and let me know if that fixes things.
oft, that sounds tricky! nice work ^^ just tested new version and it's happy days :) thanks for sorting it, much appreciated
When using these attribute
the html output doesn't seem to include the attributes, I've added them manually using
attribute("controls", "")
though as a work around.Will try take a look at this myself later.