2017-01-03 120 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> 
} 
}