Today i found out how to define variables in play’s templates. I would say play does not go the common way, instead it uses a functional approach. So to define a new variable you have to do something like:

[codesyntax lang=“html4strict“]

@defining(User.getLoggedinUser()) {user =>
  <h1>hello @user.getName(), @user.getPrename()</h1>
}

[/codesyntax]

So basically the variable user references to the result of User.getLoggedinUser(), which is an object in this case and can only be used in the defined scope of the {}.