Skip to content

Instantly share code, notes, and snippets.

@fomkin
Created July 11, 2017 15:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fomkin/0255db18107fd60c1309e34c90258ebb to your computer and use it in GitHub Desktop.
Save fomkin/0255db18107fd60c1309e34c90258ebb to your computer and use it in GitHub Desktop.
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