The Play Framework 2 template language is pretty nice. However, though it’s ‘inspired by’ Microsoft’s Razor language, one important design decision is different: how you ‘es
Here's what you might be looking for. It's not exactly FP though
structuredpage.scala.html
@(title: String)(content: scala.collection.mutable.MutableList[Pair[String, Html]] => Unit)
@main(title){
@defining(new scala.collection.mutable.MutableList[Pair[String,Html]]()) { sections =>
@content(sections)
@for(section <- sections){
@section._1
@section._2
}
}
}
frontpage.scala.html
@()
@import views.Common.section
@structuredpage("Front Page") { implicit sections =>
@section("Section 1") {
stuff
}
@section("Section 2") {
more stuff
}
}
section method:
def section(title: String)(content: Html)(implicit sections: scala.collection.mutable.MutableList[Pair[String, Html]]) {
sections += title -> content
}