From a5faaad091ec5a866dde116f474d9a6f6dda2e1c Mon Sep 17 00:00:00 2001 From: Martin Date: Fri, 1 Mar 2024 15:50:34 -0600 Subject: [PATCH] Update exporter.py --- src/invent/ui/exporter.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/invent/ui/exporter.py b/src/invent/ui/exporter.py index c1ae8c5..291be1c 100644 --- a/src/invent/ui/exporter.py +++ b/src/invent/ui/exporter.py @@ -117,9 +117,9 @@ def as_python_code(app): APP_TEMPLATE = """ App( - name={name}, + name='{name}', content=[ - {pages} +{pages} ], ) """ @@ -128,16 +128,22 @@ def as_python_code(app): def _pretty_repr_app(app): """Generate a pretty repr of the App's UI.""" - lines = [] - for page in app.content: - _pretty_repr_component(page, lines=lines, indent=" "*8) - return APP_TEMPLATE.format( name=app.name, - pages="\n".join(lines), + pages=_pretty_repr_pages(app.content) ) +def _pretty_repr_pages(pages): + """Generate a pretty repr of the pages in an App's UI.""" + + lines = [] + for page in pages: + _pretty_repr_component(page, lines=lines, indent=" "*8) + + return "\n".join(lines) + + def _pretty_repr_component(component, lines, indent=""): """Generate a pretty repr as a LIST of lines of code.