Re: [play-framework] [Play 2.0.4 - Template engine] Variables

82 views
Skip to first unread message

Julien Richard-Foy

unread,
Nov 6, 2012, 9:15:43 AM11/6/12
to play-fr...@googlegroups.com
Hi, this has nothing to do with variables. In Scala if is an expression (equivalent to the `?` of Java), so you can just write:

@inputText(
  …,
  args = '_label -> "Username", 'disabled -> if (action == "disable") "disabled" else "enabled"
)

You could define an intermediate value for the result of the `if`, if you want to:

@defining(if (action == "disable") "disabled" else "enabled") { disabled =>
  @InputText(
    …,
    args = '_label -> "Username", 'disabled -> disabled
  )
}

By the way comparing String values is a weak design, I would prefer to use an enumeration or a sum type.

Regards,
Julien

RyanT

unread,
Nov 6, 2012, 10:43:48 PM11/6/12
to play-fr...@googlegroups.com
I guess I have to start looking in Scala language...

Thanks alot,
Reply all
Reply to author
Forward
0 new messages