Reputation: 3742
Since Intellij does not yet support the Play-Scala-Template-Engine I was thinking about using plain Scala for the time being, since having no code-completion, import help really slows my development down.
Is it possible to use plain Scala, not the @-ish wrapper, as a template-engine in Play 2.0? I guess that I could simply return ok(Htmp.apply("fooo"))
from my (java) controllers and construct view-generating static methods in scala as my pseudo-templates, but I would like the overall structure of the project to similar to the "original".
To illustrate:
a normal template for my Meetings
-Controller would be stored in
/app/views/Meetings/list.scala.html
and look something akin to this:
@(currentUser: User, meetings: Set[Meeting])
@main("Possible Meeting Dates") {
@for(meeting <- meetings){
"do fancy layout"
}
}
I would want the whole thing to be stored under
/app/views/Meetings/list.scala
and contain something akin to this:
import play.api.templates._
def render(user: User, meetings:Set[Meeting]): Html = {
Html("doing the layout here")
}
So my IDE gets that this is Scala and helps accordingly. Doing the latter whilst renaming the file to list.scala.html
does not quite work: play compile
causes some reference to be generated. I am able to call
views.html.Meetings.list.render()
like expected, but it does not take any parameters.
Do I need to adhere to a certain signature for the compiler-magic to work, or does this whole Idea simply not work?
Upvotes: 1
Views: 515
Reputation: 671
I tried a very personal solutions. Reported (but not liked :-( ) here :
https://stackoverflow.com/questions/7731573/how-would-you-improve-this-scala-basic-xml-template
Hope that can of an help...
Upvotes: 1