Skip to content

Commit e69afcd

Browse files
committed
rewrite
1 parent 513f91a commit e69afcd

25 files changed

+1510
-781
lines changed

Cargo.lock

+16-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+2-6
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ repository = "https://github.com/ModProg/htmx"
1414
documentation = "https://docs.rs/htmx"
1515

1616
[features]
17-
default = ["axum", "actix-web"]
18-
sorted_attributes = []
17+
# default = ["axum", "actix-web"]
1918
axum = ["dep:axum-core"]
2019

2120
[dependencies]
@@ -30,13 +29,10 @@ serde = "1.0.188"
3029
serde_json = "1.0.107"
3130
typed-builder = {git = "https://github.com/ModProg/rust-typed-builder", branch = "mutators"}
3231
chrono = "0.4.31"
32+
ghost = "0.1.17"
3333

3434
[dev-dependencies]
3535
insta = "1.31.0"
36-
# Enables `sorted_attributes` for tests, to make assertions stable.
37-
htmx = { path = ".", default-features = false, features = [
38-
"sorted_attributes",
39-
] }
4036
serde = { version = "1.0.188", features = ["derive"] }
4137

4238
[profile.dev.package.insta]

example/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ repository = "https://github.com/ModProg/htmx"
1111
documentation = "https://docs.rs/htmx"
1212

1313
[features]
14-
default = ["axum"]
14+
default = ["axum", "tauri", "actix"]
1515
axum = ["htmx/axum", "dep:tokio", "dep:axum"]
1616
tauri = ["dep:tauri-runtime", "dep:tauri-runtime-wry", "dep:url"]
1717
actix = ["htmx/actix-web", "dep:actix-web"]

example/axum.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,17 @@ use std::error::Error;
88
use axum::response::IntoResponse;
99
use axum::routing::{get, post};
1010
use axum::{Form, Router};
11-
use htmx::{html, HtmxSrc};
11+
use htmx::{html, HtmlPage, HtmxSrc};
1212

1313
async fn index() -> impl IntoResponse {
1414
html! {
15-
<head>
16-
<HtmxSrc/>
17-
</head>
18-
<h1>"Axum Demo"</h1>
19-
<form hx::post="/greet" hx::swap="outerHTML">
20-
<input name="name" placeholder="Name"/>
21-
<button> "Greet me" </button>
22-
</form>
15+
<HtmlPage mobile title="Axum Demo" scripts=["htmx"]>
16+
<h1>"Axum Demo"</h1>
17+
<form hx::post="/greet" hx::swap="outerHTML">
18+
<input name="name" placeholder="Name"/>
19+
<button> "Greet me" </button>
20+
</form>
21+
</_>
2322
}
2423
}
2524

@@ -39,6 +38,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
3938
Router::new()
4039
.route("/", get(index))
4140
.route("/greet", post(greet))
41+
.route("/htmx", get(HtmxSrc))
4242
.into_make_service(),
4343
)
4444
.await

example/tauri.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ use std::borrow::Cow;
88
use std::error::Error;
99
use std::fmt::Display;
1010

11-
use htmx::{html, Html, HtmxSrc};
11+
use htmx::{html, HtmxSrc};
1212
use tauri_runtime::http::ResponseBuilder;
1313
use tauri_runtime::webview::{WebviewAttributes, WindowBuilder};
1414
use tauri_runtime::window::PendingWindow;
1515
use tauri_runtime::Runtime;
1616
use tauri_runtime_wry::Wry;
1717
use url::Url;
1818

19-
fn index() -> Html {
19+
fn index() -> String {
2020
html! {
2121
<head><HtmxSrc/></head>
2222
<h1>"Tauri Demo"</h1>
@@ -25,14 +25,16 @@ fn index() -> Html {
2525
<button> "Greet me" </button>
2626
</form>
2727
}
28+
.into_string()
2829
}
2930

30-
fn greet(name: impl Display) -> Html {
31+
fn greet(name: impl Display) -> String {
3132
html! {
3233
"Hello "
3334
{format!("{name}! ")}
3435
<a href="/"> ":D" </a>
3536
}
37+
.into_string()
3638
}
3739

3840
fn get_param<'a>(key: &str, url: &'a Url) -> Result<Cow<'a, str>, String> {
@@ -61,7 +63,6 @@ fn main() -> Result<(), Box<dyn Error>> {
6163
"/greet" => greet(get_param("name", &url)?),
6264
path => return Err(format!("Unknown path `{path}`").into()),
6365
}
64-
.to_string()
6566
.into_bytes(),
6667
)
6768
.unwrap())

htmx-macros/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ proc-macro = true
1919
attribute-derive.path = "../../../Rust/attribute-derive"
2020
derive_more = { version = "1.0.0-beta.6", features = ["display"] }
2121
forr = "0.2.2"
22+
html-escape = "0.2.13"
2223
htmx-script = { version = "0.1.0", path = "../htmx-script" }
24+
ident_case = "1.0.1"
2325
manyhow = "0.9"
2426
proc-macro-utils = "0.10"
2527
proc-macro2 = "1.0.66"

0 commit comments

Comments
 (0)