Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Play 2.0 Template inclusion with "backed" logic
@main("Welcome"){
...
@controllers.Menu.render("home")
...
}
package controllers;
import play.api.templates.Html;
import models.MenuItem;
public class Menu {
public static Html render(String parent) {
List<MenuItem> menuItems = MenuItem.findByParent(parent);
// more business logic...
return views.html.menu.render(menuItems);
}
}
@(menuItems: List[MenuItem])
<h2>The Menu</h2>
<ul>
@for(menuItem <- menuItems) {
<li><a href="@menuItem.url">@menuItem.title</a></li>
}
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment