In Play 1.x you could do things like &{task?.server?.name}
to print the server name if it exists or to print nothing if task
or task.server
were null. How can I get the same result in the 2.x scala templates?
I found some questions about doing this in general with Scala:
- How to check for null or false in Scala concisely?
- How to write a proper null-safe coalescing operator in scala?
but those solutions are either rather verbose or require defining your own operator. Does Play provide a quick way to do this? Or if I need to define the operator myself, where should I put it so Play finds it? (I know almost nothing about Scala at this point, though I'm trying to learn)