Skip to content

Commit

Permalink
handle libraries (other than taipy) in HTML renderer (Avaiga#1000)
Browse files Browse the repository at this point in the history
* handle libraries (other than taipy) in HTML renderer

* fix tests

* format

---------

Co-authored-by: Fred Lefévère-Laoide <[email protected]>
  • Loading branch information
FredLL-Avaiga and Fred Lefévère-Laoide authored Oct 25, 2023
1 parent 738021b commit 74a581f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/taipy/gui/_renderers/_html/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ class _HtmlFactory(_Factory):
def create_element(gui, namespace: str, control_type: str, all_properties: t.Dict[str, str]) -> t.Tuple[str, str]:
builder_html = _Factory.call_builder(gui, f"{namespace}.{control_type}", all_properties, True)
if builder_html is None:
return f"<div>INVALID SYNTAX - Control is '{namespace}:{control_type}'", "div"
return f"<div>INVALID SYNTAX - Control is '{namespace}:{control_type}'</div>", "div"
return builder_html # type: ignore
2 changes: 1 addition & 1 deletion src/taipy/gui/_renderers/_html/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def append_data(self, data: str) -> None:
def parse_taipy_tag(self) -> None:
tp_string, tp_element_name = self.taipy_tag.parse(self._gui)
self.append_data(tp_string)
self.tag_mapping[f"taipy:{self.taipy_tag.control_type}"] = tp_element_name
self.tag_mapping[f"{self.taipy_tag.namespace}:{self.taipy_tag.control_type}"] = tp_element_name
self.taipy_tag = None

def get_jsx(self) -> str:
Expand Down
4 changes: 3 additions & 1 deletion tests/taipy/gui/extension/test_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,20 +135,22 @@ def test_lib_input_html_1(gui: Gui, test_client, helpers):
'defaultValue=""',
"broadcast={_bc_broadcast}",
"value={tpec_TpExPr_val_TPMDL_0}",
"</TestLib_Input>",
]
helpers.test_control_html(gui, html_string, expected_list)


def test_lib_input_html_2(gui: Gui, test_client, helpers):
val = "" # noqa: F841
gui._set_frame(inspect.currentframe())
html_string = '<test_lib:testinput multiline="true">{val}</testlib:testinput>'
html_string = '<test_lib:testinput multiline="true">{val}</test_lib:testinput>'
expected_list = [
"<TestLib_Input",
"multiline={true}",
'defaultValue=""',
"broadcast={_bc_broadcast}",
"value={tpec_TpExPr_val_TPMDL_0}",
"</TestLib_Input>",
]
helpers.test_control_html(gui, html_string, expected_list)

Expand Down

0 comments on commit 74a581f

Please sign in to comment.