I wonder if play 2.0.3 and higher supports else if
in views? I only read that one have to code that way: if {...}else{if{...}else{...}}
cannot believe that.
标签:
playframework
相关问题
- PlayFramework: how to transform each element of a
- Could not import the newly generated play framewor
- Play Framework Unicode symbols in HTTP Header
- Putting output of 'git describe' in templa
- org.scala-sbt#sbt;${{sbt.version}}: not found on e
相关文章
- Testing request with CSRF Token in Play framework
- How to map an abstract collection with jpa?
- play2 framework my template is not seen. : package
- How does @Inject in Scala work
- play framework 2.0 - unexpected exception - Key No
- Error integration fingerprint U.are.U SDK with jav
- Custom bridge table in playframework ebean
- how to handle fileupload into a table in play fram
The @Todd Flanders answer is right. In a wrapper @{}, you can write your normal Scala code. Example
I was also able to get
to work. Keep in mind that most programming languages do not support "else if" as a lexical token. They are separate commands. The block of code executed by the "else" command happens to be an "if" statement.
Note also that you can mix XHTML with the clause:
I agree with biesior that it's usually a good idea to push state logic into the controller, then you can have different views for different states, with shared components having their own sub-views.
No, "else if" is not supported in scala templates: Does play framework 2.0 support nested if statement in template?
You can use pattern matching or you can put if inside else.
Now
if else if
is supported in latest playframework. Discussion is here https://github.com/playframework/twirl/issues/33You can use like this:
I used an @ before the second if :
You can use
switch statement
inScala
to achieve it.Example:
Translated:
Hope can help you in some cases and hope play framework will support
else if
soon.