match case in scala template doesn’t work, in play2

I was hitting the same problem. Enclosing the right part of the case in curly braces fixed the issue for me.

This works for me:

@user match {
    case Some(user) => { Welcome, @user.username! }
    case None => { <a href="https://stackoverflow.com/questions/9748258/@routes.Application.login">Login</a> }
}

Without the braces, it gave an error with the space after the { on the match line highlighted. “‘case’ expected but identifier found.”

I also gives me that error if I try to put an @ before the opening curly brace like this:

//This gives me the same error
@user match {
    case Some(user) => @{ "Welcome, " + user.username + "!" }
    case None => { <a href="https://stackoverflow.com/questions/9748258/@routes.Application.login">Login</a> }
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)