skip to Main Content

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.


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) {

notes: This is pseudo code I have no idea about Scala.



  1. Chosen as BEST ANSWER

    What I did was that:

     @defining( CourseCategory.find.all()) { courses =>
           @for(i <- courses) {
              <li><a href="#">@i.getCategoryName</a></li>

    I'm not sure if this is a good approach but it works.

  2. You can as well short it to just:

    @for(i <- CourseCategory.find.all()) {
        <li><a href="#">@i.getCategoryName</a></li>
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top