Suave Nti
Suave Nti

Reputation: 3739

PlayFramework2 Passing List to main.scala

Am using Play2.1 for one of my projects.

Am trying to create a dynamic menu in the main.scala.html so that it is extendible in all sub-pages.

but how should I pass a List to main.scala.html ..

I tried on a subpage like this

@(menu: List[Rights])
...
@for((l, index) <- menu.zipWithIndex){
    <span class="data-@index">@l.rightName</span>
}

.. That was working I can see the listed rights but all I wanted is to display these rights in main.scala.html ..Kindly suggest

Upvotes: 0

Views: 618

Answers (1)

Laky
Laky

Reputation: 965

You have @(title: String)(content: Html) at the beginning of the main.

Have you tried something like @(title: String, menu:List[Rights])(content: Html)?

You should be able to even add a default parameter, like @(title: String, menu:List[Rights] = Nil)(content: Html)

Upvotes: 1

Related Questions