scala twirl autocomplete in intelliJ outside play - scala

I'm using scala twirl templating outside the play framework (using akka-http instead) for generating email bodies, but it seems like intelliJ has no idea how to parse the twirl files (they are basically plain text files).
I would love to see some autocomplete support, etc for twirl. Is there any good plugins for that? The Scala plugin is supposed to have support for play 2.0 which should include twirl, but it seems like it won't do anything without Play.

Related

How do you use play framework as a library, in a scala project

Use Play Framework as a component got a server up, but configuring the file system paths for routes file, views, etc, give or take having to take care of a thread pool for the embedded play server is a different story. Basing on the aforementioned, I started a template for including play as a library, but it remains unclear how to wire the paths, hopefully in an IDE-import friendly way too, so that Play can be nicely used in an existing non-play project, as a library.
How do you configure the file system paths for the routes file and views?
What else should be handled for being as robust as running as the framework?
Anything special for bundling the project for deploy with Play now included?
Motivation: Adding Play to a project, in the current state of affairs, means wrapping the project definition and structure around Play, and losing full compilation in sbt (because only run completes the compilation when using the play sbt plugin). As future Spray support is vague and Akka http is beta-ish, using Play as a library seems to plug a hole.
Somehow this didn't pop up in google, until someone suggested the link on gitter: https://www.playframework.com/documentation/2.5.x/ScalaEmbeddingPlay
Note that an application.conf file containing the required crypto secret can simply sit under src/main/resources in this embedded mode (up until you want to override it for production as per the documentation about it). This is quite enough for a REST server.
However now back to the docs, in case you want more than REST:
This can be used in conjunction with the Twirl template compiler and Play routes compiler
So for Play view templates (which are twirl templates really), refer to the repo I mention in the question body, in which #JonasAnso kindly enabled exactly that.

Play Framework How to Compile Views for Distribution

I have common views that I want to share across multiple Play Framework 2.2.1 applications. I'm thinking packaging them up into a single library and publishing them to our Maven repo is the way to go, but something isn't working correctly during the compile phase.
My project has a single file My/Namespace/myView.scala.html. After compiling my package jar has a file named exactly as my view. My/Namespace/MyView.scala.html I was expecting to see some class files.
The play framework seems to do something very similar https://github.com/playframework/playframework/blob/master/framework/src/play/src/main/scala/views/helper/twitterBootstrap/twitterBootstrapFieldConstructor.scala.html and looking at their Maven package this seems to compile into a twitterBootstrapFieldConstructor class (along with all the meta classes scala generates):
I'm guessing i'm missing something in my SBT configuration that makes it compile scala.html files...but i'm just not seeing it.
Anyone have some insight into what i should be doing?
It appears the best option at this time is to make use of the Twirl library https://github.com/spray/twirl which is the template engine wrapped up into a similar but distinct API.
sbt .13 support is in a testing phase see https://github.com/spray/twirl/issues/15#issuecomment-32272389 as it appears there's going to be some reconciliation of this project & play's templating libraries (one using the other)

Can I use Play 2.1 Template Editor and autocomplete for HTML?

Is there any way to use the Template Editor and some HTML editor at the same time? I would like features like autocomplete for HTML in the Template Editor, or even CSS autocomplete.
I am currently with the Scala IDE Eclipse 3.7.2.
PS1: I am a very beginner in Play/Scala, but I decided to install Aptana (from update site) for the very small but comfortable niceties it provides, so, dropped the play template editor for a moment. Aptana has also a coffeescript editor so, it helps while I am studying backbone with cofeescript.
IntelliJ Idea with scala and play2 plugins works fine for me, autocomplete even for routes file.
I have never used Scala IDE but I know Guillaume Bort, the creator of PlayFramework, has created a Sublime Text 2 plugin for Playframework. It has autocompletion on most file types.
The problem was fixed in this release of Play plugin for the Scala Eclipse IDE:
http://scala-ide.org/blog/play-0.4.0-announcement.html

Play framework with out scala UI template

I am coming from the Java EE world. New to scala and Play. Looking at some sample applications. I see scala code in html files. I am able to understand the framework but I could not get scala.html files. Do I need to learn scala to use Play framework. Any work around.
You can use Java version of Play! without any scala skills. If you don't want to use scala.html templates you can get some module providing Java templates for Play20. Modules list can be found here.
Some examples with samples:
Groovy Template Engine for Play Framework 2.0
A full feaured Java-based template engine for Play2

Are there any Scala template engines other than scalate?

I'm tring to embed scalate in my website with sbt+jrebel, but found there are some problems I can't resolve.
So I want to know if there any other template engines based on scala?
How about popping on the Scalate group and describing the actual problems you're having? Am sure its fairly straight forward to work around? If the issue you're having is to do with sbt + jrebel and class reloading of scala code that you want to use inside your template engine; switching template engine's isn't sounding like an option (unless you want to stop using Scala in your templates). Plus Scalate is really the best and most popular template engine that uses Scala expressions inside it.
Play framework for scala has a brand new scala template engine
not sure if it can be used outside of play
http://scala.playframework.org/documentation/scala-0.9.1/templates
Pure Scala DSLs:
scala-xml (not sure how long this will be supported though)
ScalaTags
"Regular" templating engines:
Twirl
JSP (Java)
Freemarker (Java)
Velocity (Java)
Thymeleaf (Java)
Mustache.java (Java)
Thanks to String Interpolation from Scala 2.10, now we can use native syntax to generated a complex text content.
Just use Fastring. It has both good performance and simple usage.
If you're running on the JVM, Scala's interoperability with Java would let you use Velocity or Freemarker.
I might want to look at Stitchr which was largely inspired by StringTemplate
Scalasti is a Scala wrapper around StringTemplate.
As already mentioned above, I would recommend using Twirl (the template system from Play). It's now very easy to use standalone. You'll have compile time checking of your templates and many more cool and simple stuff:
https://github.com/spray/twirl