Usually I create all the stuff like that:
@(courses: List[models.Course])
Then I pass the List from the controller into the view from the render() method.
but this is some kind of special case, It’s actually a partial and I would have to add the list of courses into every method in the controllers.
logic:
main.scala.html is the main file which calls all the other views via a @content variable.
There is a twitter bootstrap navbar which get’s called into every view, I don’t want to pass the List from every controller action into the view but instead I’d like to call it like so:
pseudo code:
@List[Course] = { Course.find.all()) { courses =>
@for(c <- courses) {
@c.getCategory()
}
}
notes: This is pseudo code I have no idea about Scala.
2
Answers
What I did was that:
I'm not sure if this is a good approach but it works.
You can as well short it to just: