Spielen 2.0-templating - Scala `match` und `val` kompilieren Sie nicht in einem view-template

Ich habe den folgenden code in Spielen 2.0 Vorlage:

@content.toString.lines.map{
    case line =>     //i put `case` here as another attempt to make it work
    line match {
        case "" => @Html("")
        case _ => <li>@Html(line)</li>   /*CRASH*/
    }   
}

Es scheitert an der markierten Linie, sagen, dass not found: value line. Die zweite Variante:

@for(line <- content.toString.lines){
    @line match {                            /*CRASH*/
        case "" => @Html("")
        case _ => <li>@Html(line)</li>
    }   
}

scheitert an der markierten Linie, behauptet, dass 'case' expected but identifier found.

UPDATE:

Gleiche gilt für val:

@val headID = "head"

kommt mit illegal start of simple expression.

UPDATE ENDET

Ich würde gerne wissen, was mache ich falsch und wie man richtig implementieren die match-case Struktur und val Zuordnung im Spiel der templates?

InformationsquelleAutor noncom | 2012-04-07
Schreibe einen Kommentar