For me this fits
as an answer, for last question at least.
This just scala. Just XML built-in magic.
http://www.alvarocarrasco.com/2011/03/play-framework-and-templating-with.html?m=1
Sample:
This is a template: Templates.scala file
package templates
import play.api.templates.Html
import scala.xml.Xhtml
import controllers.routes
object Main {
def page (title:String="Default title")(content: => scala.xml.Elem) = Html {
"<!DOCTYPE html>" +
Xhtml.toXhtml(
<html>
<head>
<title>{title}</title>
<link rel="stylesheet" media="screen" href={routes.Assets.at("stylesheets/main.css").toString()} />
<link rel="shortcut icon" type="image/png" href={routes.Assets.at("images/favicon.png").toString()} />
<script src={routes.Assets.at("javascripts/jquery-1.9.0.min.js").toString()} type="text/javascript" />
</head>
<body>
{content}
</body>
</html>
)
}
// a panel template, just as an example
def panel (label:String="Some label")(content: => scala.xml.Elem) = {
<div class="panel">
<div class="panel-label">{label}</div>
<div>{content}</div>
</div>
}
}
This is an index page index.scala file
package views
import templates.Main._
object IndexPage {
def apply() = {
page(title="Welcome to my Page!") {
<div>
<h1>Hello</h1>
<p>Some template markup</p>
{
panel(label="Dashboard panel")(
<div>
Panel content
</div>
)
}
</div>
}
}
}
This is a controller: Application.scala file
package controllers
import play.api.mvc._
object Application extends Controller {
def index = Action {
Ok(
views.IndexPage()
);
}
}