在play 2中声明一个scala变量

时间:2017-01-03 07:57:51

标签: playframework-2.2

我想在视图文件中声明一个scala变量。怎么办呢?

    @(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 个答案:

答案 0 :(得分:0)

为了完整起见,我通过此代码解决了我的问题

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