Skip to content

Syntax similar to JSX #918

Open
Open
@Archmonger

Description

@Archmonger

Current Situation

ReactJS has a method of HTML templating called JSX. We currently do not have an equivalent. We need to create a Python-based JSX equivalent that operates similarly to how it is used in ReactJS (Javascript).

The key difference here is we will not use a dedicated file extension (such as .psx) in order to not break existing toolchains. Instead, we will rely on the tag string PEP that adds template literals to Python. Here is an example of the tag string syntax:

from reactpy import html

button_style = {"font_style": "bold"}
button_text = "Click me!"
view = html(t"<button on_click={lambda event: ...} style={button_text}>{button_text}</button>")

While we wait for the tag string PEP to be merged, we could potentially use an interim transpiler to use a similar syntax. The interim transpiler syntax would look something like this:

from reactpy import html

button_style = {"font_style": "bold"}
button_text = "Click me!"
view = html @ f"<button on_click={lambda event: ...} style={button_text}>{button_text}</button>"

Proposed Actions

Aid in the development of this proposed transpiler and then develop an html tag function. An initial implementation of an html tag can be found here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority-2-moderateShould be resolved on a reasonable timeline.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions