Skip to content

Embedding ReactPy via Template Tags #653

Closed

Description

@Archmonger

Current Situation

Currently, users are expected to manually construct the component mount HTML needed to embed IDOM into their projects. This is results in poor usability, and even worse, it can very easily cause server/client version mismatches.

Proposed Actions

We need to increase the convenience embedding ReactPy into existing projects, and document this as the primary way of using IDOM

For any web framework that supports HTML templating, we really should use a system identical to that used on ReactPy-Django.

The template tag source code will look something like this

{% load static %}
<div id="{{ idom_mount_uuid }}" class="{{ class }}"></div>
<script type="module" crossorigin="anonymous">
  import { mountViewToElement } from "{% static 'django_idom/client.js' %}";
  const mountPoint = document.getElementById("{{ idom_mount_uuid }}");
  mountViewToElement(
    mountPoint,
    "{{ idom_websocket_url }}",
    "{{ idom_web_modules_url }}",
    "{{ idom_ws_max_reconnect_timeout }}",
    "{{ idom_component_id }}",
    "{{ idom_component_params }}"
  );
</script>

We will probably rely on the jinja2 simple tags library.

To be framework agnostic, the static URL will probably need to be set via ReactPy's python config.

Activity

  1. changed the title [-]IDOM embed shortcuts for all supported frameworks[/-] [+]Improve IDOM Embed ease of use[/+] on Feb 8, 2022
  2. changed the title [-]Improve IDOM Embed ease of use[/-] [+]Make embedding IDOM easier[/+] on Feb 8, 2022
  3. Archmonger commented on Feb 10, 2022

    @Archmonger
    ContributorAuthor

    Not really sure if this belongs in v1 or v2. Could go either way.

    IDOM is technically usable without this, but only Django-IDOM feels convenient to develop in.

    We did say v2 is for "niceities" though, so based on that logic this is a v2 task.

  4. added
    priority-3-lowMay be resolved one any timeline.
    type-docsAbout changes and updates to documentation
    and removed on Feb 10, 2022
  5. added this to the milestone on Feb 16, 2022
  6. modified the milestones: , 1.0 on Apr 8, 2022
  7. changed the title [-]Make embedding IDOM easier[/-] [+]Embedding IDOM via Template Tags[/+] on Apr 8, 2022
  8. rmorshea commented on Nov 5, 2022

    @rmorshea
    Collaborator

    Let's move this to v2 for now.

  9. modified the milestones: 1.0, on Nov 5, 2022
  10. removed this from the milestone on Jan 29, 2023
  11. changed the title [-]Embedding IDOM via Template Tags[/-] [+]Embedding ReactPy via Template Tags[/+] on Jun 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority-3-lowMay be resolved one any timeline.type-docsAbout changes and updates to documentation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions