Scala natively supports xml syntax and, by extension, xhtml. So no DSL, just a language feature.
Why is it possible to write HTML inside Scalatra?
Question
Take the following example :
package com.example.app
import org.scalatra._
import scalate.ScalateSupport
class MyServlet extends ScalatraServlet with ScalateSupport {
get("/") {
<html>
<body>
<h1>Hello, world!</h1>
Say <a href="hello-scalate">hello to Scalate</a>.
</body>
</html>
}
}
Is this a DSL? i am wondering about the mechanism of how this work.
Solution
OTHER TIPS
Scala has support of XML literals on language level.
Scala's XML literal syntax is actually sugar for a series of Elem and Text instantiations
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow