Skip to content

Commit 9a4caa4

Browse files
committed
class condition support
1 parent 12bb905 commit 9a4caa4

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Sources/SwiftHtml/Html/Attributes/Global.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,12 @@ public extension Tag {
3838
node.upsert(Attribute(key: "accesskey", value: String(value)))
3939
return self
4040
}
41-
41+
4242
/// Specifies one classname for an element (refers to a class in a style sheet)
43-
func `class`(_ value: String) -> Self {
44-
node.upsert(Attribute(key: "class", value: value))
43+
func `class`(_ value: String, _ condition: Bool = true) -> Self {
44+
if condition {
45+
node.upsert(Attribute(key: "class", value: value))
46+
}
4547
return self
4648
}
4749

0 commit comments

Comments
 (0)