Tuesday, 17 September 2013

Play Framework Scala Template

Play Framework Scala Template

I've worked around with Play Framework for a while but I'm almost new to
Scala Templates . For me as a C-familiar language developer sometimes it
looks a bit strange
I was wondering if someone here could help me understand this code better
I took it from http://www.playframework.com/documentation/2.2.x/JavaGuide3
(Zentask Example)
@(projects: List[Project], todoTasks: List[Task])
@main("Welcome to Play") {
<header>
<hgroup>
<h1>Dashboard</h1>
<h2>Tasks over all projects</h2>
</hgroup>
</header>
<article class="tasks">
@todoTasks.groupBy(_.project).map {
case (project, tasks) => {
<div class="folder" data-folder-id="@project.id">
<header>
<h3>@project.name</h3>
</header>
<ul class="list">
@tasks.map { task =>
<li data-task-id="@task.id">
<h4>@task.title</h4>
@if(task.dueDate != null) {
<time datetime="@task.dueDate">
@task.dueDate.format("MMM dd
yyyy")</time>
}
@if(task.assignedTo != null &&
task.assignedTo.email != null) {
<span
class="assignedTo">@task.assignedTo.email</span>
}
</li>
}
</ul>
</div>
}
}
</article>
}
This 3 lines are really confusing for me :
@todoTasks.groupBy(_.project).map {
case (project, tasks) => {
@tasks.map { task =>
I do appreciate if anyone can explain me in more details what exactly
these 3 lines are doing?
Thanks guys

No comments:

Post a Comment