MCPcopy Index your code
hub / github.com/reactive-python/reactpy / vdom_to_html

Function vdom_to_html

src/py/reactpy/reactpy/utils.py:62–78  ·  view source on GitHub ↗

Convert a VDOM dictionary into an HTML string Only the following keys are translated to HTML: - ``tagName`` - ``attributes`` - ``children`` (must be strings or more VDOM dicts) Parameters: vdom: The VdomDict element to convert to HTML

(vdom: VdomDict)

Source from the content-addressed store, hash-verified

60
61
62def vdom_to_html(vdom: VdomDict) -> str:
63 """Convert a VDOM dictionary into an HTML string
64
65 Only the following keys are translated to HTML:
66
67 - ``tagName``
68 - ``attributes``
69 - ``children`` (must be strings or more VDOM dicts)
70
71 Parameters:
72 vdom: The VdomDict element to convert to HTML
73 """
74 temp_root = etree.Element("__temp__")
75 _add_vdom_to_etree(temp_root, vdom)
76 html = cast(bytes, tostring(temp_root)).decode()
77 # strip out temp root <__temp__> element
78 return html[10:-11]
79
80
81def html_to_vdom(

Callers 3

test_vdom_to_htmlFunction · 0.90
test_vdom_to_html_errorFunction · 0.90

Calls 1

_add_vdom_to_etreeFunction · 0.85

Tested by 2

test_vdom_to_htmlFunction · 0.72
test_vdom_to_html_errorFunction · 0.72