2017-01-03 76 views
0

我想在视图文件中声明一个scala变量。如何做呢?在声明中声明一个scala变量2

@(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> 
+0

的可能的复制[玩2.0中创建一个变量,并赋值(http://stackoverflow.com/questions/11232772/玩-2-0-创建-A-可变和分配值) –

回答

0

为了完整起见,我解决我的问题,这段代码

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