Skip to content

Commit

Permalink
Apparently I forgot PyScript FFI docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Archmonger committed Dec 14, 2024
1 parent c5f8d68 commit fa13697
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
14 changes: 14 additions & 0 deletions docs/examples/python/pyscript_ffi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from pyscript import document, window
from reactpy import component, html


@component
def root():
def on_click(event):
my_element = document.querySelector("#example")
my_element.innerText = window.location.hostname

return html.div(
{"id": "example"},
html.button({"onClick": on_click}, "Click Me!"),
)
12 changes: 10 additions & 2 deletions docs/src/reference/template-tag.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,17 @@ The entire file path provided is loaded directly into the browser, and must have
{% include "../../examples/python/pyodide_js_module.py" %}
```

**PyScript FFI**
**PyScript Foriegn Function Interface (FFI)**

...
PyScript FFI has similar functionality to Pyodide's `js` module, but utilizes a different API.

There are two importable modules available that are available within the FFI interface: `window` and `document`.

=== "root.py"

```python
{% include "../../examples/python/pyscript_ffi.py" %}
```

**PyScript JS Modules**

Expand Down

0 comments on commit fa13697

Please sign in to comment.