/js-scala

js.scala: JavaScript as an embedded DSL in Scala

Primary LanguageScala

js.scala: JavaScript as an embedded DSL in Scala

Documentation

Setup

  1. Setup virtualization-lms-core.

  2. Run sbt. test to ensure everything works. Then publish-local.

Use it in your project

  1. Add a dependency on js-scala-0.3-SNAPSHOT
  2. Set the Scala organization to org.scala-lang.virtualized
  3. Set the -Yvirtualize compiler option

Use it in Play! 2.1

Tweak your project/Build.scala file to look like the following:

object ApplicationBuild extends Build {

    val appName         = "foo"
    val appVersion      = "1.0-SNAPSHOT"

    val appDependencies = Seq(
      "EPFL" %% "js-scala" % "0.3-SNAPSHOT"
    )

    val main = play.Project(appName, appVersion, appDependencies).settings(
      scalaOrganization := "org.scala-lang.virtualized",
      scalacOptions ++= Seq("-deprecation", "-unchecked", "-Xexperimental", "-Yvirtualize")
    )

}

Use it in Play! 2.0.2

  • build-play20 builds Play 2! and all its transitive Scala dependencies with Scala-Virtualized, for compatibility with this DSL. Deployment on dotcloud is an option.

Further projects

  • play-js-validation uses this DSL to enable form validation code in Play 2.0 to be written once and checked on both client and server sides.

  • forest uses this DSL to enable HTML templates to be written once and shared between client and server sides, both for initial rendering and automatic updating.