Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ServerState._repr_html_ #36

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions streamlit_server_state/server_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
class ServerState(collections.abc.MutableMapping):
__items__: Dict[str, ServerStateItem] = {}

def _repr_html_(self):
# TODO: Escape to be HTML-safe as this is directly passed to
# TODO: st.markdown with unsafe_allow_html=True.
return dict(self)

def _ensure_item(self, k: str) -> ServerStateItem:
if k in self.__items__:
item = self.__items__[k]
Expand Down