irundaia
irundaia

Reputation: 1730

Scalatags conditional attribute

I'm trying to write a wrapper around the select element. So in principle I want to be able to specify that given some boolean multiple I want to append the multiple attribute or not. Below I've given a small example:

select (id := someId, name := someName, if (multiple) "multiple".attr := "")

This obviously won't compile, but it should convey my intent.

Upvotes: 0

Views: 424

Answers (1)

Ajay Padala
Ajay Padala

Reputation: 2401

You can try:

val attrList = if (multiple) List("multiple".attr = "") else List.empty
select (id := someId, name := someName)(attrList:_*)

This way its conditional whether you add that attribute or not.

Upvotes: 1

Related Questions