Kotlin notebook is cool for testing my custom HTML...
# datascience
j
Kotlin notebook is cool for testing my custom HTML DSL framework
K 3
a
You can add a rendered for your type and it will be event cooler.
r
@Jason Zhao Yep, if you add something like
Copy code
USE {
  render<WH>{ it.let { HTML(it.toString() } }
}
in the beginning of your notebook, or in [the notebook integration](https://github.com/Kotlin/kotlin-jupyter/blob/master/docs/libraries.md) class, then objects of
WH
type will always be rendered in a correct way
j
Unfortunately my WH class is inline
value class
and the renderer doesn't seem to like working on it.
It's a value class over
StringBuilder
so I'm guessing the notebook is treating it like a stringbuilder.
Also whenever I change the code I always need to restart the runtime or I seemingly always get "exception during IR lowering" when running my code. Is this a bug or just a result of how the notebook works?
Here is the rendering when I manually call the HTML render function
a
Yes, Inline classes are not that stable in scripting implementation. It is possible to add a notebook-only extension like this:
Copy code
class WHWrapper(val value: VH)

fun WH(block: WH.()->Unit) = WHWrapper(WH().apply(block))
Then add an integration for WHWrapper.
i
@Jason Zhao please file a bug with exception during IR lowering here It looks like a scripting bug
Regarding value classes: rendering is based on runtime reflection now, and this information is lost at runtime...Please vote for this issue: https://github.com/Kotlin/kotlin-jupyter/issues/421