I'm confused about: ```companion object { ...
# kotlinx-html
r
I'm confused about:
Copy code
companion object {
        fun <R> TagConsumer<R>.kpis() {
vs
Copy code
companion object {
        fun FlowContent.kpis() {
I want to call this function: a) from the DSL b) when building an html fragment like this:
Copy code
fun render(): String {
        return buildString {
            appendHTML().kpis()
        }
    }
I can make the FlowContent variation at least compile with:
Copy code
fun render(): String {
        return buildString {
            appendHTML().div { 
                kpis()
            }
        }
    }
... but it blows up in weird ways
well, specifically it blows up with:
Copy code
java.lang.IllegalArgumentException: Tag svg has invalid attribute name xmlns
	at kotlinx.html.stream.HTMLStreamBuilder.onTagStart(stream.kt:30)
	at kotlinx.html.consumers.DelayedConsumer.processDelayedTag(delayed-consumer.kt:59)
	at kotlinx.html.consumers.DelayedConsumer.onTagStart(delayed-consumer.kt:10)
...however, this function rendered just fine when it was included in a whole page dsl. it's only as a fragment that it dies
or, with xmlns commented out:
Copy code
java.lang.IllegalStateException: You can't change tag attribute because it was already passed to the downstream
	at kotlinx.html.consumers.DelayedConsumer.onTagAttributeChange(delayed-consumer.kt:16)
	at kotlinx.html.impl.DelegatingMap.put(delegating-map.kt:27)
	at kotlinx.html.impl.DelegatingMap.put(delegating-map.kt:5)
where, again, it was fine as part of the whole page
e
Hey, @Reuben Firmin. Could you log github issues with repro?
r
Yes, sure.