Created
July 11, 2017 15:52
-
-
Save fomkin/0255db18107fd60c1309e34c90258ebb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class Style(xs: Map[String, String]) { | |
def +(s: Style) = Style(xs ++ s.xs) | |
def mkString = xs | |
.map { case (k, v) => s"$k: $v;" } | |
.mkString(" ") | |
} | |
object Style { | |
def apply(xs: (String, String)*): Style = Style(xs.toMap) | |
implicit def styleToString(s: Style): String = s.mkString | |
} | |
//---------------- | |
'h1( | |
'style /= Style( | |
"border" -> "1px soid", | |
"background-color" -> "red", | |
) | |
"My title" | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment