posit-dev / py-htmltools

Tools for HTML generation and output
MIT License
19 stars 2 forks source link

Make Tag objects usable as context managers #76

Closed jcheng5 closed 9 months ago

jcheng5 commented 9 months ago

When used as a context manager, upon exit, the tag displays itself.

TODO: Currently, the tag just appends its "children" to itself. This is probably too simplistic. We need to decide how this code, Shiny Express's top-level, and @display_body/@render.display go from sys.displayhook to UI, hopefully in a unified way.

Note: CI tests are failing because I intentionally left a type error in 👆 part of the code.

jcheng5 commented 9 months ago

Ideally I'd want to use IPython.core.display but that seems like a heavy dependency to take, if we can get 95% of the way by doing something simpler in htmltools/shiny.