Skip to content

Commit 7f64866

Browse files
committed
Add test
1 parent 58f0f29 commit 7f64866

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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 s: Seq[Int] => // error
14+
case e: AppliedAttr =>
15+
sb.append(" ").append(e)
16+
}
17+
sb
18+
}

0 commit comments

Comments
 (0)