Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Write raw html code inside kotlinx.html DSL

Tags:

html

kotlin

I am using Kotlin's html library kotlinx.html for dynamic html building.

For debugging proposes I want to write a tag as a raw html. But I can't find any method that would do it. Simple text addition replaces characters like < to their codes, so it does not help:

StringBuilder().appendHTML().html {
    body {
        +"""
        <form action="http://courier-voddan.rhcloud.com/customer/new_task" method="get">
            get=form
            id=3333
            <button type="submit">ok</button>
        </form>
        """.trimIndent()
    }
}
like image 680
voddan Avatar asked Dec 12 '15 09:12

voddan


1 Answers

Simply use unsafe inside your tag to prevent HTML encoding.

body {
    unsafe {
       +"""<form class="formClass"/>"""
    }
}
like image 64
Mathias Parger Avatar answered Sep 29 '22 22:09

Mathias Parger