from restan import tags as T, js, flatten
tree = T.p(
onclick=js.document.write(T.div(onclick=js.alert('"'))["plop"])
)["lol"]
flatten(tree)
>>>'<p onclick="document.write(\'<div onclick="alert(\\\'&quot;\\\')">plop</div>\')">lol</p>'