ido
unread,Feb 7, 2012, 11:55:33 AM2/7/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to play-framework
I am trying to nest scala calls in a template, but fail:
I even tried putting some of the function in its own template but
still failed.
I am tring to put 10 items in a row, if its a None at this index,
empty td
I also miss an explanation for $@ notation in the wiki for templating.
case class Item1(map: Map[Int,String]) {
def item(index: Int): Option[String] = map.get(index)
}
-------
"expected start of definition" (at (index).map))
@(items: Seq[Item1])
items.map{ row =>
<tr>
@{(1 to 10).map{ index =>
@row.item(index).map(s => <td>@s</td>).getOrElse(<td></
td>)
}}
</tr>
}
------
"identifier expected but { found"
@(items: Seq[Item1])
items.map{ row =>
<tr>
@{(1 to 10).map{ index =>
@{row.item(index).map(s => <td>s</td>).getOrElse(<td></td>)}
}}
</tr>
}
-----
not found: value row
@(items: Seq[Item1])
items.map{ row =>
<tr>
@{(1 to 10).map{ index =>
row.item(index).map(s => <td>s</td>).getOrElse(<td></td>)
}}
</tr>
}
-----
"expected start of definition" }}
@(items: Seq[Item1])
@display(item: Item1, index: Int){
@item.item(index).map(s => <td>s</td>).getOrElse(<td></td>)
}
items.map{ row =>
<tr>
@{(1 to 10).map{ index =>
@display(row, index)
}}
</tr>
}
-----
same result with simple template