diff --git a/spec/blueprint/html/attributes_parser_spec.cr b/spec/blueprint/html/attributes_parser_spec.cr index 9b20156..b99a43c 100644 --- a/spec/blueprint/html/attributes_parser_spec.cr +++ b/spec/blueprint/html/attributes_parser_spec.cr @@ -9,7 +9,7 @@ private class DummyPage section(v_model: "user.name", "@click": "doSomething") { "Transform attribute name" } input(disabled: true, checked: false, outline: "true", border: "false") nav(aria: {target: "#home", selected: "false", enabled: true, hidden: false}) { "Nested attributes" } - div(class: ["a", "b", ["c", "d"]]) { "Array attributes" } + div(class: ["a", nil, "b", ["c", nil, "d"]]) { "Array attributes" } end end @@ -59,7 +59,7 @@ describe "Blueprint::HTML attributes parser" do page.to_html.should contain(nav) end - it "flattens and joins array attributes" do + it "flattens, compacts and joins array attributes" do page = DummyPage.new nav = <<-HTML.strip
Array attributes
diff --git a/src/blueprint/html/attributes_parser.cr b/src/blueprint/html/attributes_parser.cr index 3713a64..f1636b0 100644 --- a/src/blueprint/html/attributes_parser.cr +++ b/src/blueprint/html/attributes_parser.cr @@ -36,7 +36,7 @@ module Blueprint::HTML end private def append_array_attribute(io : String::Builder, attribute_name, attribute_value : Array) : Nil - append_normal_attribute(io, attribute_name, attribute_value.flatten.join(" ")) + append_normal_attribute(io, attribute_name, attribute_value.flatten.compact.join(" ")) end private def process_named_tuple_attribute(io : String::Builder, attribute_name, attribute_value : NamedTuple) : Nil