f9e46d12
—
Peter John 3 years ago
v0.3.1
- Cargo.toml +1 -1
- src/lib.rs +12 -2
Cargo.toml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "tide-jsx"
|
|
3
|
-
version = "0.3.
|
|
3
|
+
version = "0.3.1"
|
|
4
4
|
authors = ["pyrossh", "Gal Schlezinger <gal@spitfire.co.il>"]
|
|
5
5
|
edition = "2021"
|
|
6
6
|
description = "A safe and simple template engine with the ergonomics of JSX"
|
src/lib.rs
CHANGED
|
@@ -8,12 +8,22 @@ mod text_element;
|
|
|
8
8
|
|
|
9
9
|
pub use self::render::Render;
|
|
10
10
|
pub use fragment::Fragment;
|
|
11
|
+
use tide::{http::mime, StatusCode};
|
|
11
12
|
pub use tide_jsx_impl::{component, html, rsx};
|
|
12
13
|
pub use simple_element::SimpleElement;
|
|
13
14
|
pub use text_element::Raw;
|
|
14
15
|
|
|
15
16
|
impl<'a, T: Render> From<SimpleElement<'a, T>> for tide::Response {
|
|
16
|
-
fn from(s: SimpleElement<T>) -> Self {
|
|
17
|
+
fn from(s: SimpleElement<'a, T>) -> Self {
|
|
17
|
-
tide::
|
|
18
|
+
tide::Response::builder(StatusCode::Ok)
|
|
19
|
+
.content_type(mime::HTML)
|
|
20
|
+
.body(s.render())
|
|
21
|
+
.build()
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
impl<'a, T: Render> From<SimpleElement<'a, T>> for tide::Result {
|
|
26
|
+
fn from(s: SimpleElement<'a, T>) -> Self {
|
|
27
|
+
Ok(s.into())
|
|
18
28
|
}
|
|
19
29
|
}
|