Play2.0テンプレートにブール属性/データ属性を追加する方法は?

StackOverflow https://stackoverflow.com//questions/11672411

  •  12-12-2019
  •  | 
  •  

質問

誰かが追加する方法を知っていますか boolean attributes のように autofocus scalaテンプレートに?

例を示します。: autofocus:

<input autofocus />

今のところ私は使用します:

'autofocus -> "autofocus"

これは印刷します:

<input type="text" autofocus="autofocus" />

カスタムデータ属性を追加する方法は?ありがとう!

役に立ちましたか?

解決

使用 None, 、このように:

@inputText(
  loginForm("username"),
  '_label -> Messages("usernameLabel"),
  'required -> None,
  'autofocus -> None
)

次のような要素を出力します:

<input type="text" id="username" name="username" value="" required autofocus>

他のヒント

これは機能しますが、それでもscalaにはもっと簡単な方法があるはずだと思います!

'autofocus -> "autofocus"
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top