-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Zohaib Sibte Hassan
committed
Dec 25, 2023
1 parent
d1b21d0
commit 070beb2
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,4 +75,37 @@ def header(account: AccountInfo) -> DOMElement: | |
domx.h1(f"Welcome {account.name}"), | ||
hamburger(account) # Reusing another component | ||
) | ||
``` | ||
|
||
### More usage examples: | ||
|
||
Here is an example app Sanic: | ||
|
||
```python | ||
from sanic import Sanic, html | ||
from htmxido import domx as x | ||
|
||
app = Sanic("Pythia") | ||
|
||
@app.post("/clicked") | ||
async def clicked(request): | ||
return html(str( | ||
x.div("Clicked!!!") | ||
)) | ||
|
||
@app.get("/") | ||
async def home(request): | ||
return html(str( | ||
x.html( | ||
x.head( | ||
x.script(src="https://unpkg.com/[email protected]") | ||
), | ||
x.body( | ||
x.h1("Running htmxido"), | ||
x.div(id="container")( | ||
x.button("Reveal!!!", hxTarget="#container", hxTrigger="click", hxPost="/clicked") | ||
), | ||
) | ||
) | ||
)) | ||
``` |