Java Reference
In-Depth Information
Listing 8-11. Simple Template
@(books: List[Book])
<ul>
@for(book <- books) {
<li>@book.getTitle()</li>
}
</ul>
You can then call this from any Java code like you would normally call a method on a class.
Content html = views.html.Application.index.render(books);
Listing 8-12 illustrates the code for the index.scala.html template that you will find in the
app/views folder.
Listing 8-12. index.scala.html
1. @(books: List[Book], bookForm: Form[Book])
2.
3. @import helper._
4.
5. @main("books") {
6.
7. <h1>@books.size() book(s)</h1>
8.
9. <ul>
10. @for(book <- books) {
11. <li>
12. @book.label
13.
14. @form(routes.Application.deleteBook(book.id)) {
15. <input type="submit" value="Delete">
16. }
17. </li>
18. }
19. </ul>
20.
21. <h2>Add a new book</h2>
22.
23. @form(routes.Application.newBook()) {
24.
25. @inputText(bookForm("label"))
26.
27. <input type="submit" value="Create">
28.
29. }
30.
31. }
 
Search WWH ::




Custom Search