From be58d59d2be2a3de99650dd4f090f83cff4bd9cf Mon Sep 17 00:00:00 2001 From: "Yuichiro Tachibana (Tsuchiya)" Date: Sun, 26 Sep 2021 15:46:26 +0900 Subject: [PATCH] [WIP] Add ServerState._repr_html_ --- streamlit_server_state/server_state.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/streamlit_server_state/server_state.py b/streamlit_server_state/server_state.py index d8f994e..1fa3455 100644 --- a/streamlit_server_state/server_state.py +++ b/streamlit_server_state/server_state.py @@ -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]