Preventing HTML encoding in kotlinx.html DSL

269 views Asked by At

I am using kotlinx.html DSL to generate an HTML DIV. One of the DIV's attributes is a URL with & in it. e.g. Parameter url below is https://www.example.com?a=1&b=2

fun createDiv(url: String): DIV.() -> Unit {
  return {
    attributes["data-url"] = url
  }
}

I was hoping to generate
<div data-url="https://www.example.com?a=1&b=2">
But I am actually getting
<div data-url="https://www.example.com?a=1&amp;b=2">

How can I prevent the URL from being HTML encoded? Thanks!

P.S. I've tried unsafe. But my actual DIV is a bit too complex to be put into an unsafe construct as a string. I am using Kotlin 1.4.

0

There are 0 answers