spray / twirl Goto Github PK
View Code? Open in Web Editor NEWThe Play framework Scala template engine, stand-alone and packaged as an SBT plugin
License: Apache License 2.0
The Play framework Scala template engine, stand-alone and packaged as an SBT plugin
License: Apache License 2.0
Hi,
There's a bug in the Play framework template compiler, that causes it to fail to properly lookup scala-library.jar
and scala-compiler.jar
.
The corresponding ticket for @playframework is ticket-944 in their issue tracker. The fix is planned for Play 2.1.1.
(The ticket title mentions Windows XP, but that's a type and should be Windows 2003.)
You can find the fix in my fork of Play20 in this commit, which applies to TemplateCompiler
in Twirl as well.
Our build server runs on Windows 2003, and I already have to maintain an internal fork of Play20, which works as expected with the aforementioned fix.
Best regards
I cloned the repository, published it locally, went into example directory and issued: sbt run
twirl-compile: java.lang.NoClassDefFoundError: twirl/compiler/TemplateCompilationError
Currently twirl does not support includes, as like the Play documentation:
Again, there’s nothing special here. You can just call any other template you like (and in fact any other function coming from anywhere at all):
[info] Resolving cc.spray#sbt-twirl;0.5.2 ...
[error] sbt-plugin-releases: bad sbtVersion found in http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases/cc.spray/sbt-twirl/scala_2.9.2/sbt_0.12/0.5.2/ivys/ivy.xml: expected='0.12' found='0.11.3'
[error] sbt-plugin-releases: bad scalaVersion found in http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases/cc.spray/sbt-twirl/scala_2.9.2/sbt_0.12/0.5.2/ivys/ivy.xml: expected='2.9.2' found='2.9.1'
[error] sbt-plugin-releases: bad sbtVersion found in http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases/cc.spray/sbt-twirl/scala_2.9.2/sbt_0.12/0.5.2/ivys/ivy.xml: expected='0.12' found='0.11.3'
[error] sbt-plugin-releases: bad scalaVersion found in http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases/cc.spray/sbt-twirl/scala_2.9.2/sbt_0.12/0.5.2/ivys/ivy.xml: expected='2.9.2' found='2.9.1'
it would be great, if sbt.013 would be supported :-)
I've got an old Scala app I'm slowing converting over to SBT. It still has some Spring 3 stuff in it (yea I know, I know. I will rip it out soon) and I have one thing in my application context that looks like so:
<bean id="convertersAsScalaMap" class="scala.collection.JavaConversions" factory-method="mapAsScalaMap">
<constructor-arg ref="converters"/>
</bean>
The trouble is, when I add Twirl.settings to the bottom of my build.sbt, my entire application breaks. I see this in my logs coming from Spring:
Cannot resolve reference to bean 'convertersAsScalaMap' while setting bean property 'converters'; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [scala.collection.JavaConversions] for bean with name 'convertersAsScalaMap' defined in class path resource [io/bigsense/spring/spring.xml]; nested exception is java.lang.ClassNotFoundException: scala.collection.JavaConversions
I've narrowed it down to the Twirl.settings. If I comment it out, I can't use templates of course, but I no longer see this exception from calling the same set of beans. I'm on sbt 0.13.0 and Scala 2.10.3. My sbt-twirl plugin in 0.7.0.
Does the twirl plugin do something weird that makes JavaConversions inaccessible? I'd really like to use the Play2 template engine to replace my old JSPs.
Here is the source code: https://github.com/sumdog/BigSense/ (Revision 7431e80 and the one right before it on the reengineering branch)
Twirl headline says "stand-alone and packaged as an SBT plugin".
As of today is it possible to run twirl compiler as a stand-alone task without SBT dependency?
There's a bug that existed in Play where the template compiler throws a NoSuchElement exception when trying to access the left projection of an Either$RightProjection. A fix was pulled into Play 2.0, and I'd like to port it to twirl.
The stack trace looks like this:
java.util.NoSuchElementException: Either.left.value on Right
at scala.Either$LeftProjection.get(Either.scala:287)
at twirl.compiler.TwirlCompiler$TemplateAsFunctionCompiler$TreeCreationMethods$class.treeFrom(TwirlCompiler.scala:638)
at twirl.compiler.TwirlCompiler$TemplateAsFunctionCompiler$PresentationCompiler$.treeFrom(TwirlCompiler.scala:645)
at twirl.compiler.TwirlCompiler$TemplateAsFunctionCompiler$TreeCreationMethods$class.treeFrom(TwirlCompiler.scala:623)
at twirl.compiler.TwirlCompiler$TemplateAsFunctionCompiler$PresentationCompiler$.treeFrom(TwirlCompiler.scala:645)
at twirl.compiler.TwirlCompiler$TemplateAsFunctionCompiler$.getFunctionMapping(TwirlCompiler.scala:549)
at twirl.compiler.TwirlCompiler$.generateFinalTemplate(TwirlCompiler.scala:488)
at twirl.compiler.TwirlCompiler$.compile(TwirlCompiler.scala:186)
at twirl.sbt.TemplateCompiler$$anonfun$compile$3.apply(TemplateCompiler.scala:46)
at twirl.sbt.TemplateCompiler$$anonfun$compile$3.apply(TemplateCompiler.scala:44)
at scala.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:60)
at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:47)
at twirl.sbt.TemplateCompiler$.compile(TemplateCompiler.scala:44)
at twirl.sbt.TwirlPlugin$Twirl$$anonfun$settings$4.apply(TwirlPlugin.scala:50)
at twirl.sbt.TwirlPlugin$Twirl$$anonfun$settings$4.apply(TwirlPlugin.scala:50)
etc
References:
Play 2.0 bug report - for some reason it was never resolved
Play 2.0 github pull request - this has a fix
[Google Search](scala.tools.nsc.interactive.FreshRunReq play) - many reports of the same issue
It'd be great if it was possible to use jade in the same way as twirl, i.e. as a stand-alone template engine available to SBT.
Possibly this would entail implementing support for several different language "plugins"....
Hi
We're unable to use the Twirl plugin. I get the following error:
Unresolved dependencies: io.spray#twirl-api_2.10;0.6.2
I have tried to go back to an earlier version:
libraryDependencies += sbtPluginExtra(
m = "io.spray" % "sbt-twirl" % "0.6.2", // Plugin module name and version
sbtV = "0.12", // SBT version
scalaV = "2.9.2" // Scala version compiled the plugin
)
Still no dice. Could you please release a 2.10 build into repos?
I've created a maven plugin for twirl for which I also need the twirl api as a compile and runtime dependency (for the generated code). The api code is at https://github.com/tomdz/twirl-api. I was wondering if you guys would be open to publishing the twirl api code (and maybe the compiler stuff) as separate artifacts to sbt & maven repos under the spray namespace ?
We should probably make it 'utf8' by default and make it configurable for other cases.
Given that https://github.com/playframework/twirl seems to be actively developed it would be nice to point to it from wiki page.
Please consider backporting patches like e.g.: playframework/playframework#2151
I get the following error when trying to set twirlImports in my build.sbt file
error: reassignment to val
twirlImports := Seq("my.lib")
I'm trying to build the example in Arch Linux, and I have sbt 0.12.0
I've tried with tags v0.6.0, v0.6.1, and master, all having the same issue when I launch sbt in the example directory:
sbt.ResolveException: unresolved dependency: com.typesafe.akka#akka-actor;2.0.1: not found
at sbt.IvyActions$.sbt$IvyActions$$resolve(IvyActions.scala:214)
at sbt.IvyActions$$anonfun$update$1.apply(IvyActions.scala:122)
at sbt.IvyActions$$anonfun$update$1.apply(IvyActions.scala:121)
at sbt.IvySbt$Module$$anonfun$withModule$1.apply(Ivy.scala:114)
at sbt.IvySbt$Module$$anonfun$withModule$1.apply(Ivy.scala:114)
at sbt.IvySbt$$anonfun$withIvy$1.apply(Ivy.scala:102)
at sbt.IvySbt.liftedTree1$1(Ivy.scala:49)
at sbt.IvySbt.action$1(Ivy.scala:49)
at sbt.IvySbt$$anon$3.call(Ivy.scala:58)
at xsbt.boot.Locks$GlobalLock.withChannel$1(Locks.scala:75)
at xsbt.boot.Locks$GlobalLock.withChannelRetries$1(Locks.scala:58)
at xsbt.boot.Locks$GlobalLock$$anonfun$withFileLock$1.apply(Locks.scala:79)
at xsbt.boot.Using$.withResource(Using.scala:11)
at xsbt.boot.Using$.apply(Using.scala:10)
at xsbt.boot.Locks$GlobalLock.liftedTree1$1(Locks.scala:51)
at xsbt.boot.Locks$GlobalLock.withLock(Locks.scala:51)
at xsbt.boot.Locks$.apply0(Locks.scala:30)
at xsbt.boot.Locks$.apply(Locks.scala:27)
at sbt.IvySbt.withDefaultLogger(Ivy.scala:58)
It seems akka-actor-2.0.1 is quite old, and couldn't be found in maven repo.
Is there a specific way of building the example that I don't know of?
I'm trying to use twirl as part of my integration tests.
My integration tests have an HTTP simplicator that mimics a real world service. To implement this simplicator in the tests, I'm using spray-can embedded HTTP server which needs to spit out responses based on twirl templates.
My tests are located at /src/it/scala so naturally I want to place these twirl templates inside /src/it/twirl. This doesn't work since the twirl compiler ignores this directory.
If I place the twirl templates in /src/main/twirl, everything works fine - but I'm trying to avoid this because I don't want these templates to clutter the production package (the templates only come into play in the tests so they should only compile inside when the tests are run).
How can I tell the twirl compiler to look for templates in the new directory?
Currently twirl pulls in Akka since it's dependent on 0.4.1, but all IO is synchronous, so make it depend on 0.4.1-seq (less dependencies).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.