Skip to content

Client-side Python components #229

Closed
@Archmonger

Description

@Archmonger

Current Situation

While it's currently not possible to implement in core, we can use our template tag to render client-side components within this repo as a Django exclusive early release.

Proposed Actions

Develop client side components with multiple execution methods. The initial draft will be based on reactive-python/reactpy#1096

We need to make sure the interface makes the user understand that the whole file is going to be loaded into the browser.

Here's a quick draft of potential API designs:

{% component "example.hello_world" client_side_render="pyscript" %}
{% component "file:/example/components.py:hello_world" executor="pyscript" %}
{% client_component "/example/components.py:hello_world" executor="reactpy_django.client.pyscript" %}
{% pyscript_component "/example/components.py:hello_world" %}
{% pyscript_component "/example/components.py" root="hello_world" %}

We should also create a callable variant that can be used as a child within server side components.

@component
def parent_component():
    return html.div( pyscript_component("/example/components.py", root="hello_world") )

It seems logical that the root component should be def root(...) by default.

We may also want to minify the python code we generate. Minification should be toggleable through minify=False
Not feasible since minification would rename the root component

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions