Skip to content

Commit 70cd501

Browse files
authored
Merge pull request #14 from celtric/stop_rendering_empty_attributes
Stop rendering empty attributes
2 parents e00c425 + 96cfc4d commit 70cd501

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ buildscript {
1313
}
1414

1515
group "org.celtric.kotlin"
16-
version "0.1.3"
16+
version "0.1.4"
1717

1818
apply plugin: "kotlin"
1919
apply plugin: "maven-publish"

src/main/kotlin/org/celtric/kotlin/html/_building_blocks.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ operator fun List<Node>.plus(text: String): List<Node> = plus(Text(text))
9595
typealias Attributes = Map<String, Any?>
9696

9797
private fun Attributes.renderAttributes(prefix: String = "") =
98-
filter { it.value != null && it.value != false }
98+
filter { it.value != null && it.value != false && it.value != "" }
9999
.map { Pair(it.key, if (it.value is Boolean) "" else "=\"${it.value}\"") }
100100
.joinToString("") { " " + prefix + it.first + it.second }
101101

src/test/kotlin/org/celtric/kotlin/html/AttributesTest.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,9 @@ internal class AttributesTest {
2929
span(other = mapOf("foo" to true)) { "Content" }
3030
.assertRenders("<span foo>Content</span>")
3131
}
32+
33+
@Test fun empty_attributes() {
34+
span(classes = "", other = mapOf(), data = mapOf()) {}
35+
.assertRenders("<span></span>")
36+
}
3237
}

0 commit comments

Comments
 (0)