Reuben Firmin
04/22/2024, 5:07 PMMario Palka
05/29/2024, 7:42 PMli is unresolved reference?Kirill Gagarski
05/30/2024, 11:27 PM<label><input type=checkbox checked name=cheese disabled> Cheese</label>
I am aware about checked="checked" or checked="" options and how to do it with kotlinx.html, but I want the exact syntax as above in the outputAnders Sveen
06/11/2024, 12:00 PMCies
06/11/2024, 2:55 PMFormDto . The library sets a standard for the names (the name attribute on HTML form fields) so they can be used to provide a structure to the data.Cies
06/11/2024, 2:55 PMCies
06/11/2024, 2:56 PMAhmed
07/12/2024, 6:09 PMAhmed
07/14/2024, 2:10 AMBernhard
07/20/2024, 10:24 PMMario Andhika
08/06/2024, 2:18 AMrobnik
08/15/2024, 3:00 PM<link rel="preconnect" href="<https://fonts.gstatic.com>" crossorigin>
This guess doesn't work (crossorigin is not a parameter).
link(rel="preconnect", href="<https://fonts.gstatic.com>", crossorigin=true)Cies
10/15/2024, 8:31 AM/** Evaluate a TemplateRenderer block into a String. Used in email rendering. */
fun stringFromHtml(renderer: TemplateRenderer): String {
return StringBuilder().apply {
append("<!DOCTYPE html>\n")
appendHTML().renderer()
}.toString()
}
/** Evaluate a TemplateRenderer block into a RePlay RenderHtml Result. <------- so this would be different for KTor! */
fun resultFromHtml(renderer: TemplateRenderer): RenderHtml {
return RenderHtml(stringFromHtml(renderer))
}
typealias TemplateRenderer = TagConsumer<*>.() -> Unit
typealias LayoutBuilder<T> = TagConsumer<*>.(data: T, renderer: TemplateRenderer) -> Unit
fun <T> layout(builder: LayoutBuilder<T>): LayoutBuilder<T> {
return { data, renderer -> builder(data, renderer) }
}
// In a render method we simply do:
fun render(input: Whatever): RenderHtml {
return resultFromHtml {
table {
tr {
+input.toString()
}
}
}
}Cies
10/15/2024, 8:32 AMCies
10/15/2024, 8:37 AMdmcg
10/15/2024, 9:22 AMfun partial(block: FlowContent.() -> Unit): String {
val writer = StringWriter()
val consumer = writer.appendHTML()
// hacky stuff so we don't have to return a wrapper div
object : FlowContent {
override val consumer = consumer
override val attributes: MutableMap<String, String>
get() = mutableMapOf()
override val attributesEntries: Collection<Map.Entry<String, String>>
get() = emptyList()
override val emptyTag: Boolean
get() = true
override val inlineTag: Boolean
get() = true
override val namespace: String?
get() = null
override val tagName: String
get() = ""
}.block()
return writer.toString()
}
I don’t know the library well enough to choose between the approaches, but thanks giving for your experience.Tim Schraepen
10/15/2024, 12:58 PMe5l
10/16/2024, 7:07 AMReuben Firmin
10/16/2024, 11:37 AMAnders Sveen
11/13/2024, 4:28 PMReuben Firmin
12/05/2024, 3:49 PMMikael Ståldal
01/01/2025, 7:50 PMMikael Ståldal
01/03/2025, 3:24 PMe5l
01/15/2025, 12:49 PMMario Andhika
02/04/2025, 3:02 AMBernhard
03/11/2025, 12:19 PMAlex Styl
08/08/2025, 7:36 AM<html> tag?
I want to be able to output html like <div></div> but it seems like i am forced to create it like <html><div></div></htmlAlex Styl
10/01/2025, 8:21 AMsuspend fun DIV.Download(classes: String="") {
unsafe {
+"""
<svg xmlns="<http://www.w3.org/2000/svg>" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="$classes"><path d="M12 15V3"/><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><path d="m7 10 5 5 5-5"/></svg>
""".trimIndent()
}
}
However I want to be able to use them from any tag (ie inside div or a . What should i use as the receiver type?Alex Styl
10/16/2025, 2:59 AMsvg tag doesn't support path ? if that's the case how do you do svgs?