How to ad "data-" attributes in Scalatags

1.1k Views Asked by At

I want to define an input with extended attributes using the "data-" notation. So for example to define:

<input type="radio" id="3" data-extra="three"/>

Is there a way to do this in Scalatags?

3

There are 3 best solutions below

2
On BEST ANSWER

You can use "data-extra".attr to create custom attributes. For example

input(tpe := "radio", id := "3", "data-extra".attr := "three")
0
On

Now even

input(tpe := "radio", id := 3, data.extra := "three")

0
On

The most convinient way is to use data(...):

input(tpe := "radio", id := 3, data("extra") := "three")