Support for else if
@marcusatbang @adis-me @npcode @xuwei-k asked for else if in https://github.com/playframework/playframework/issues/1376 and I'm moving the issue here
It would be nice to write something like this in the views:
@if(something) {
...
} else if (somethingElse) {
...
} else {
...
}
At present you have to nest if/else statements or use a match/case statement.
And what about?
@fooSeq.map { foo =>
...
} else {
...
}
instead of:
@if(!fooSeq.isEmpty) {
@fooSeq.map { foo =>
…
}
} else {
...
}
And this:
@fooOption.map { foo =>
...
} else {
...
}
instead of:
@fooOption.map { foo =>
...
}.getOrElse {
...
}
I know it is not a huge necessity, but it would be more readable.
@adrianhurt
implicit class OptionOps[T](a: Option[T]) {
def `else`[R >: T](body: => R) = {
a.getOrElse(body)
}
}
+1000
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
Has this been implemented yet? Just curious?
This has not been implemented.
@wsargent Thanks.