Skip to content

Commit cc3a8d7

Browse files
committed
Add test
1 parent 58f0f29 commit cc3a8d7

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
object HTML:
2+
type AttrArg = AppliedAttr | Seq[AppliedAttr]
3+
opaque type AppliedAttr = String
4+
opaque type AppliedTag = StringBuilder
5+
6+
case class Tag(name: String):
7+
def apply(attrs: AttrArg*): AppliedTag = {
8+
val sb = StringBuilder()
9+
sb.append(s"<$name")
10+
attrs.filter(_ != Nil).foreach{
11+
case s: Seq[AppliedAttr] =>
12+
s.foreach(sb.append(" ").append)
13+
case e: AppliedAttr =>
14+
sb.append(" ").append(e)
15+
}
16+
sb
17+
}

0 commit comments

Comments
 (0)