declare a scala variable in play 2

51 views Asked by At

I want to declare a scala variable in a view file. How can it be done?

    @(title: String)(content: Html)
    //this line isnt compiling. I tried without the word defining but it doesn't work either
    @defining(l:Seq[String] = Seq("hello","hello2"))
 <html><head>...   
        <body>
            @content
    //I want to use the list here
            <ul id="hardcode-list" >
              @l.map{item=><li>item</li>}
            </ul>
        </body>
    </head></html>
1

There are 1 answers

0
Manu Chadha On

for completeness sake, I solved my issues by this code

<ul id="hardcode-list" >
@defining(List("hello","hello2")){l=>
@l.map{item=>
<li>@item</li>  
} 
}