diff --git a/questionpy_sdk/webserver/question_ui/__init__.py b/questionpy_sdk/webserver/question_ui/__init__.py index 9382fe0..87fc9d9 100644 --- a/questionpy_sdk/webserver/question_ui/__init__.py +++ b/questionpy_sdk/webserver/question_ui/__init__.py @@ -246,17 +246,27 @@ def render(self) -> tuple[str, RenderErrorCollection]: tuple: The rendered html and a render errors collection. """ if self._html is None: - self._resolve_placeholders() + # Handle our custom elements and attributes. self._hide_unwanted_feedback() self._hide_if_role() + self._shuffle_contents() + self._format_floats() + + # Remove all unhandled custom elements, attributes, and non-default xmlns declarations. + self._clean_up() + + # Modify standard HTML. self._set_input_values_and_readonly() self._soften_validation() self._defuse_buttons() - self._shuffle_contents() + self._add_styles() - self._format_floats() + + # We don't want to support QPy elements (and attributes, etc.) in placeholder expansions, so we resolve + # them after replacing QPy elements. + self._resolve_placeholders() + # TODO: mangle_ids_and_names - self._clean_up() self._html = etree.tostring(self._xml, pretty_print=True, method="html").decode() self._error_collector.collect() @@ -270,10 +280,8 @@ def _replace_qpy_urls(self, xml: str) -> str: def _resolve_placeholders(self) -> None: """Replace placeholder PIs such as `` with the appropriate value from `self.placeholders`. - TODD: remove comment or change call-order - Since QPy transformations should not be applied to the content of the placeholders, this method should be called - last. + near the end (see `_clean_up` method). """ for p_instruction in _assert_element_list(self._xpath("//processing-instruction('p')")): if not p_instruction.text: