3

Templates from the Play! framework compile to Scala and seem to be a nice fit for a scala.js project to use for client-side templating. How hard is it to use them in a scala.js project? Since I'm very new to both Scala and sbt, detailed instructions would be much appreciated.

Alternatively, is there any other template engine which would be better suited for use with scala.js?

2 Answers 2

2

I don't think it will be possible to use Play! templates in Scala.js just yet. The problem is that compiled Play! templates refer to Play! libraries, including

import play.templates._
import play.templates.TemplateMagic._
import play.api.templates._
import play.api.templates.PlayMagic._
import play.api.i18n._
import play.api.mvc._
import play.api.data._

These are only compiled for the JVM, and I would be surprised if they can be retargeted at Scala.js trivially.

To manipulate HTML trees in Scala.js, I recommend ScalaTags. Although not strictly speaking a template library, it can be used to do the same job as a template library.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, ScalaTags looks real sweet.
1

You can clone this repository and start there.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.